Also:
From http://www.myke.com/basic.htm: Incrementing/Decrementing "w"
Here are a couple of snippets that will allow you to increment and decrement the "w" register without affecting any file registers if you don't have "addlw"/"sublw" instructions (ie in the case of the low-end processor)."Reg" can be any register that does not change during the execution of the three instructions. For the low-end parts, any file register can be used because there is no danger of them being updated by an interrupt handler.
To Increment:
xorlw 0x0FF ; Get 1s Complement of Number addwf Reg, w ; w = Reg + (w^0x0FF) subwf Reg, w ; w = Reg + ((Reg + (w^0x0FF))^0x0FF) + 1 ; w = w + 1To decrement, the instructions are re-arranged:
subwf Reg, w ; w = Reg + (2^0x0FF) + 1 xorlw 0x0FF ; Get 1s Complement of Result addwf Reg, w ; w = w - 1
Archive:
Questions: