From Scott Dattalo
;inc incf high,f incfsz low,f decf high,f A downcounting version; ;dec movf low,f skpnz decf high,f decf low,f on the 18cxxx you can simplify these to: infsnz low,f incf high,f and tstfsz low,f decf high,f decf low,fThanks to Colin Smith for corrections to this page
Al Williams of AWC Says:
Slight typos in the 18F code above for decrement. TSTFSZ doesn't put a result anywhere, so no ,F is required. Also, should be testfsnz but that instruction doesn't exist!+
So in fact, you should use the 16F version for decrementing. Also, be aware that the Z flag may be set after this operation but the counter is not zero (just part of it).
Decrement Counters at 18F: decf CounterLow, f btfss STATUS, C decf CounterHigh, f btfss STATUS, C decf CounterUpper, f and so on... Check for Carry-flag in Loops Loops will execute Counter+1 times. After Loop's exit, Counter == -1.+
decf16 macro file ; Decrease 16bit file, Z flag correct movf file,f ; Check low byte skpnz ; Low byte zero? decf file+1,f ; Yes, need to decrement HB as well decf file,f ; Decrement low byte skpnz ; Skip if no further checks needed to set Z movf file+1, f ; LB is zero, now check HB endm+
|file: /Techref/Microchip/math/incdec/best16.htm, 2KB, , updated: 2017/2/13 12:44, local time: 2017/8/22 19:36,
|©2017 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?|
<A HREF="http://www.piclist.com/Techref/Microchip/math/incdec/best16.htm"> PIC Math Increment / Decrement Best 16Bit</A>
|Did you find what you needed?|
PICList 2017 contributors:
o List host: MIT, Site host massmind.org, Top posters @20170822 RussellMc, Van Horn, David, James Cameron, IVP, alan.b.pearce, Sean Breheny, Neil, Bob Blick, David C Brown, Denny Esterline,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
Welcome to www.piclist.com!