Disclosure: This post contains affiliate links and I may be compensated if you make a purchase after clicking through one of my links.
This post will cover the ARITHMETIC AND LOGIC OPERATIONS GROUP. Instructions for the PIC micro controller. The Arithmetic and logic operations of the micro controller (PIC) perform all math and logic internal functions. The mathematical operations performed include are addition, subtraction, multiplication, and division. The Logic operations performed include AND, OR, NOT, and XOR.
The first instruction to be presented is ADDLW.
ADDLW— This instruction performs the addition operation by adding a constant to the content of the W register.
Purpose: To add a given constant to the content of the W reg.
Operation: (w) + k to w
Operand: 0 < k < 255
Memory needed: 1
Machine Cycles: 1
Flags: C, DC, Z
ADDWF— This instruction adds the contents of the f register with that of the W register. The result is stored in the W register if ‘d’ is zero. The result is stored in the f register if ‘d’ is one.
Purpose: Add the W register content to the f register content and place the results in W or f.
Operation: (w) + (f) to w if d = 0 and (w) + (f) to f if d = 1
Operand: 0 < f < 127
Memory needed: 1
Machine cycles: 1
Flags affected: C, DC, Z
SUBLW — This instruction subtracts the contents of the W register ) from the eight-bit literal ‘k’. The result is placed in the W register
Purpose: Subtract W from Literal ‘k’ and place the results in the W register.
Operation: k – (W) ® (W)
Operand: 1< k < 255
Memory needed: 1
Machine cycles: 1
Flags affected: C, DC, Z
SUBWF —This instruction Subtracts W content from f register.
Purpose: W register content is subtracted from that of register f
Operation: f – (w) to w if d = 0 and f – (w) to f if d = 1
Operand: 0 < f < 127
Memory required: 1
Machine cycles: 1
Flags affected: C, DC, Z
ANDLW — This logical instruction is used to perform a Logic AND function with a given constant and the content of the W register.
Purpose: Given constant is .and. with W reg.
Operation: (w) .and. k to w
Operand: 0 < k < 255
Memory required: 1
Machine cycles: 1
Flags affected: Z
I will continue with the rest of the PIC instruction set soon.
Return to Robotics Posts List