On Sat, 20 Mar 2010, PICdude wrote: > Quoting Josh Koffman : > > > ... > > I think I get the basic gist of what's going on, but I don't > > understand the use of constants in a couple of the commands, > > specifically: > > > > MOVLW 0100H - 060H > > and > > RETLW 0100H - 024H > > > > I'm not really sure why constants in an equation are used here rather > > than just the result of the equation. > > > Now for the rightmost seconds digit, the test value is 6, but for > leftmost digit of the seconds, the rollover point is when the '5' in > 0x59 changes to a '6' (as in 0x60). To test for that, he temporarily > adds whatever will cause 0x60 to rollover to 0x100 (to set the carry > flag), and rather than doing the math, my guess is that it's somewhat > self-commenting to use '0x100 - 0x60'. > Yes it is common practice to use expressions that show how a constant is derived rather than the derived constant itself. This helps understand the code (self-commenting) and makes it MUCH easier to identify and change constants while you are debugging it or when you need to look at it at a later date. e.g. ; 5 is the number of slots available ; 2 is the number of reserved slots addlw 5-2 is easier to understand than ; 5 is the number of slots available ; 2 is the number of reserved slots addlw 3 Regards Sergio Masci -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist