Tutorial (4): Arithmetic Instructions in PIC microcontrollers

3 months ago
76

The tutorial presents the following:
- ADDLW k : adds literal and w (w = w+k)
- ADDWF f,d: adds w and f (w= w+f) or (f= w+f)
- INCF f : increment f (f=f+1)
- SUBLW k: subtracts w from literal (w= k-w)
- SUBWF f,d: subtracts w from f (w=f-w) or (f=f-w)
- DECF f: decrement f (f=f-1)
Status register bits Zero, Carry and Digit Carry respond to certain arithmetic instructions.
The Subtract instructions follow a similar pattern to the Add
The Carry bit now, however, acts as a Borrow.
If a subtract occurs and the result is positive, then the Carry bit is ‘set’. If the result is negative, then the Carry bit is ‘clear’

Define two constant and apply the arithmetic operations between them.

Loading 1 comment...