11
Nikixandra T. Beltran Advanced Logic Circuit BS Computer Engineering Ms. Katherine Royena Classification of Instruction Set in PIC 1. Data Transfer Group 2. Arithmetic and Logic Operations Group 3. Bit Operation Group Instruction Data Transfer Group 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)

Logic Circuit

Embed Size (px)

DESCRIPTION

Logic Circuit

Citation preview

Page 1: Logic Circuit

Nikixandra T. Beltran Advanced Logic Circuit

BS Computer Engineering Ms. Katherine Royena

Classification of Instruction Set in PIC

1. Data Transfer Group

2. Arithmetic and Logic Operations Group

3. Bit Operation Group Instruction

Data Transfer Group

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)

Page 2: Logic Circuit

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

Page 3: Logic Circuit

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: –

Page 4: Logic Circuit

Arithmetic and Logic Operations Group

Arithmetic and logic operation group instructions are used for performing all arithmetic

operations and logic operations. By using these types of instructions, the PIC chip can easily

perform all arithmetic and logic operations inside the micro controller (PIC). The arithmetic

operations are addition (ADD), subtraction (SUB), multiplication (MUL), division (DIV) and logical

operations are AND, OR, NOT, XOR, and so on. The basic Arithmetical and Logical operations

that are performed by a PIC is given below.

1) ADDLW – “ADDLW” instruction is used for performing addition operation (adding a constant

with W register). By using this instruction, we can add two bits easily and the result value can be

stored in another register or memory location.

Syntax: Label ADDLW k

Description: Given constant is added with W reg.

Operation: (w) + k to w

Operand: 0 < k < 255

No. of words: 1

No. cycles: 1

Flags: C, DC, Z

2) ADDWF – “ADDWF” is also used for performing the addition operation. This ADDWF instruction

adds the constant with W register.

Syntax: Label ADDWF f, d

Description: Add W reg. content with f register

Operation: (w) + (f) to w if d = 0 and (w) + (f) to f if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: C, DC, Z

Page 5: Logic Circuit

3) SUBLW – “SUBLW” used for performing subtraction function which can be subtracting two

values and can be stored to another memory location. This instruction helps to Subtract W content

from given constant.

Syntax: Label SUBLW k

Description: W reg. content is subtracted from k

Operation: k – (w) to w

Operand: 0 < k < 255

No. of words: 1

No. cycles: 1

Flags: C, DC, Z

4) SUBWF – SUBWF is used for performing subtraction operation. In SUBLW, this instruction

Subtracts W content from f register.

Syntax: Label SUBWF f

Description: W reg. content is subtracted from f

Operation: f – (w) to w if d = 0 and f – (w) to f if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: C, DC, Z

5) ANDLW – ANDLW is a logical instruction which used for performing Logic AND. By using this

instruction helps AND the constant with W.

Syntax: Label ANDLW k

Description: Given constant is .and. with W reg.

Operation: (w) .and. k to w

Operand: 0 < k < 255

Page 6: Logic Circuit

No. of words: 1

No. cycles: 1

Flags: Z

6) IORLW – This command is used for performing logical OR operation. By using this instruction,

it will perform Logical OR operation with W register.

Syntax: Label IORLW k

Description: Given constant is .or. with W reg.

Operation: (w) .or. k to w

Operand: 0 < k < 255

No. of words: 1

No. cycles: 1

Flags: Z

7) IORWF – Logic OR the W reg. with f

Syntax: Label IORWF f, d

Description: W reg. is .or. with f reg.

Operation: (w) .and. f to w, if d = 0 and (w) .and. f to f, if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: Z

8) XORLW – This command is used for performing logical XOR operation. By using this

command, it will perform logical XOR with Logic constant and W register.

Syntax: Label XORLW k

Description: Given constant is .XOR. with W reg.

Operation: (w) .xor. k to w

Page 7: Logic Circuit

Operand: 0 < k < 255

No. of words: 1

No. cycles: 1

Flags: Z

9) XORWF – This command used to perform Logic XOR the W reg. with f

Syntax: Label XORWF f, d

Description: W reg. is .xor. with f reg.

Operation: (w) .and. f to w, if d = 0 and (w) .and. f to f, if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: Z

10) INCF – INCF command used for performing increment operations.(Increment f registers

content)

Syntax: Label INCF f, d

Description: Increment the content of f register

Operation: (f) + 1 to w, if d = 0 and (f) + 1 to f, if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: Z

11) DECF – DECF command used for performing Decrement f register content

Syntax: Label DECF f, d

Description: Decrement the content of f register

Page 8: Logic Circuit

Operation: (f) – 1 to w, if d = 0 and (f) – 1 to f, if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: Z

12) RLF – RLF command is used for performing rotate register content left through Carry

Syntax: Label RLF f, d

Description: Rotate f content left through Carry

Operation: Result to w, if d = 0 and Result to f, if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: C

13) RRF – RRF command used for perform Rotate register content right through Carry

Syntax: Label RRF f, d

Description: Rotate f content right through Carry

Operation: Result to w, if d = 0 and Result to f, if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: C

14) COMF – COMF command for perform Complement f registers content

Syntax: Label COMF f, d

Description: Complement the register content

Page 9: Logic Circuit

Operation: Result to w, if d = 0 and Result to f, if d = 1

Operand: 0 < f < 127

No. of words: 1

No. cycles: 1

Flags: Z

Bit Operation Group Instructions

1) BCF – BCF is a resetting command instruction used for performing reset operations for a

specified bit or specified register (simply called bit clearing flag or bit clearing command).

Normally BCF resets the specified bit in f registers content.

Syntax: Label BCF f, b

Description: Reset the specified bit of register f

Operation: Result to f

Operand: 0 < f < 127 and 0 < b < 7

No. of words: 1

No. cycles: 1

Flags: nil

2) BSF – BSF is the inversing operation of BCF. This is also a bitwise operation. The BSF

instruction will set the specified bit in the f register (simply called Bit Set Flag or Bit Set command).

Syntax: Label BSF f, b

Description: Set the specified bit of register f

Operation: Result to f

Operand: 0 < f < 127 and 0 < b < 7

No. of words: 1

No. cycles: 1

Page 10: Logic Circuit

Flags: nil

List All the Instruction in Pic16f84a Instruction Set and Its Function

Page 11: Logic Circuit

References:

http://www.circuitstoday.com/data-transfer-group-instructions-in-pic

http://www.circuitstoday.com/arithmetic-and-logic-operations-group-in-pic

http://www.circuitstoday.com/bit-operation-group-instructions-in-pic

http://picmicrocontrollersworld.blogspot.com/2012/01/pic16f84a-list-of-instructions.html