Pedro J Barrios wrote: > Would you please explain me what is being done in these > instructions: > > > MOVLW 0100H - 060H <--------------------- ???? > > [and] > > RETLW 0100H - 024H <- ------------------- ???? Pedro: I can't tell whether you're asking what the instructions DO, or what they MEAN, so I'll answer both: The first instruction, "MOVLW 0100H-060H" loads the W register with the hexadecimal number A0 (100 hex minus 60 hex = A0 hex). Similarly, the second instruction returns from the subroutine and loads W with DC hex. I could have replaced these with "MOVLW 0A0H" and "RETLW 0DCH" (or by the decimal equivalents "MOVLW 160" and "RETLW 220"), but then the code wouldn't hint so strongly as to its purpose, which is: The "MOVLW 0100H-060H" is followed by an "ADDWF INDF,W". Since INDF points to either the SECONDS or MINUTES register, the ADDWF has the effect of setting the Carry flag if SECONDS or MINUTES is (greater than or) equal to 60 hex. After the ADDWF, the code checks the Carry flag to determine whether the SECONDS or MINUTES register has reached 60; if it has, that register is cleared and the "SKPNC/INCF INDF" at the top of the subroutine increments the MINUTES or HOURS register, respectively. The "RETLW 0100H-024H" has no effect when INDF is pointing at either MINUTES or SECONDS; when INDF is pointing at HOURS, though, the code at SUB2 (when it's reached from the "GOTO SUB2") adds 0100H-024H to the HOURS register, setting the Carry flag if HOURS is (greater than or) equal to 24. If the Carry flag's set after the ADDWF, the HOURS register is cleared. I know this doesn't make much sense... As we've discussed here before, really tight code is often VERY hard to follow. -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - Vista, California === http://www.geocities.com/SiliconValley/2499 === For PICLIST help (including "unsubscribe" instructions), === put the single word "help" in the body of a message and === send it to: listserv@mitvma.mit.edu