|
Re: 16 bit math on PIC
its not as hard as you have psyched yourself up for.
You subtract the lower byte first, and check the carry flag. If there is a carry you subtract one from the upper byte, then subtract the upper bytes. If the number was less than 2000 the upperbyte will have the msb set (negative) when you are done.
I dont remember the instruction set off the top of my head, but many µC have 'subtract with carry' instructions, that take care of the carry for you.
|