From: Dwayne Reid
...here is an example that takes the value in R1H,M,L and adds it to the value contained in AD2H,M,L (result in AD2H,M,L). You should be able to see how to extend it to more than 24 bits.
There is a similar version that does subtraction. I often extend to 40 bits or more - its easier to do this when manipulating integer values than it is to try and figure out which bits I can discard.
;now add new sample
movfw R1L ;
addwf AD2L,F ;LS byte
movfw R1M ;middle byte
skpnc
incfsz R1M,W
addwf AD2M,F ;
movfw R1H ;MS byte
skpnc
incfsz R1H,W
addwf AD2H,F ;
Code:
;********** ; For 17C family processors. ; from std.ins.aspic at http://www.embedinc.com/pic if fam_17 add24 macro dest, src, temp movfp src+0, wreg addwf dest+0 ;add byte 0 movfp src+1, wreg addwfc dest+1 ;add byte 1 movfp src+2, wreg addwfc dest+2 ;add byte 2 endm endif ;end of 17C processor case ;
See also:
| file: /techref/microchip/math/add/24b.htm, 11KB, , updated: 2007/9/24 01:01, local time: 2009/11/21 10:24,
38.107.191.101:LOG IN
|
| ©2009 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? Please DO link to this page! Digg it! <A HREF="http://piclist.com/techref/microchip/math/add/24b.htm"> PIC Microcontoller Math Method </A> |
| Did you find what you needed? |
|
PIC Microcontroller Instruction Set Quick Reference and Core Comparison Matrix |
Robotics nuts!Check out http://www.verinet.com/~dlc/ email: dlc@verinet.com... This guy ROCKS! He has made (and sells but also releases code, docs, etc...) for a number of cool little robotic modules including whiskers, IR proximity detect and remote control, Sonar proximity detect, PWM, Servo, compass. Most of these use the little PIC 12C508 controller which costs basically nothing and is soooo tiny.The 4 servos, 2400 baud serial servo controller is a wonder of magic and he sells the programmed chip for $8. Wow! |
.