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. > > Also, am I correct in assuming SKPNC is "skip if no carry" and SKPDC > is "skip if yes carry"? I've never really been able to find out > exactly where those special instuctions come from. This is what I figure is happening here... All math is being done in packed BCD format, so when the seconds go from 0x09, then next value should be 0x10. But incrementing will take 0x09 to 0x0A, so he tests to see if that BCD-clock rollover point has reached the 'A' in the right digit by adding '6', which would take it to 0x10. If adding 6 does roll it over, the DC bit is set, and this is his indication to leave it alone now. DC is actually Digit Carry, and gets set when the lower nibble overflows. IIRC it does not work for incf, but for addwf it does. The instruction set section of the datasheets tell you which instructions affect which status bits, and this explains those bits better... http://www.pictutorials.com/The_Status_Register.htm Back to the code, if adding 6 does not cause the digit carry, then he undoes the 6-addition. 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'. Cheers, -Neil. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist