Take a look at the basics and other related articles.

PERIPHERAL INTERFACE CONTROLLER (PIC)

PIC PROGRAMMING – INSTRUCTION SETS

INTRODUCTION TO PIC 16F877

Data Transfer Group Instructions in PIC

Data transfer group instructions are one of the major instructions widely used in PIC programming for data transfer purposes. By using these types of instructions, we can move or change the value (bits) from one location to another.

Data Transfer Instructions with Syntaxes

1. MOVLW

“MOVLW” instruction is used to write constant in W register (move the value from literal to W register).

  • Syntax:

Label MOVLW k

  • Description:

8 bit constant is written in W reg.

  • Operation:

k to (W)

  • Operand:

0 < k < 255

  • No. of words: 1
  • No. cycles: 1
  • Flags: Nil

2. MOVWF

MOVWF instruction is used to move the data (bits) from W register to flag register F (copy/move the value from W register to F register).

  • Syntax:

Label MOVWF f

  • Description:

Content of W is copied into f register (flag register).

  • Operation:

W to (f) (W register to Flag register)

  • Operand:

0 < f < 127

  • No. of words: 1
  • No. cycles: 1
  • Flags: Nil

3. MOVF

MOVF command is used for copy/move the contents (bits) in the flag register to D register (Copy f to d register).

D register (destination register) is a special register which can be switchable in its destination according to its status. If the status of D register is ‘0’, the destination is W register and if the status is ‘1’, the destination of D register became F register (flag)

  • Syntax:

Label MOVF f, d

  • Description:

Content of f is copied into destination.

If d = 0, the destination is W register

If d = 1, the destination is f register

  • Operation:

F to (D)

  • Operand:

0 < k < 127

  • No. of words: 1
  • No. cycles: 1
  • Flags: Z

4. CLRW

CLRW is a clearing instruction that helps to reset the values of W register to ‘0’ (write ‘0’ in W register).

  • Syntax:

Label CLRW

  • Description:

Zero is copied into W register

Z flag in status register is set to one

  • Operation:

0 to (W)

  • Operand: nil
  • No. of words: 1
  • No. cycles: 1
  • Flags: Z

5. CLRF f

CLRF f Write ‘0’ in F register that helps to reset the current status to ‘0’

  • Syntax:

Label CLRF f

  • Description:

Zero is copied into f register

Z flag in status register is set to one

  • Operation:

0 to (f)

  • Operand: nil
  • No. of words: 1
  • No. cycles: 1
  • Flags: Z

6. SWAPF

SWAPF used for swap (interchanging functions) functions which Swap the nibbles (4bits).The destination of this function depends on the destination register status.

  • Syntax:

Label SWAPF f, d

  • Description:

Upper, Lower nibbles are exchanged

If d = 0, the destination is W register

If d = 1, the destination is f register

  • Operation:

f (0:3) to d(4:7) and f(4:7) to d(0:3)

  • Operand:

0 < f < 127

  • No. of words: 1
  • No. cycles: 1
  • Flags: —
Author

2 Comments

  1. ok, you are always welcome to our circuitstoday.if you hav any doubts pls fell free ask here

  2. Thank you very much for these leçons about the PIC. In fact, I studied the PIC but I didn’t understand anything because the teacher is nil…. from Algeria…