View Single Post
  #2   Spotlight this post!  
Unread 02-10-2005, 22:43
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
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.