> From: Shane Nelson > Subject: clock code challenge: > Hi, > After having seen the amazing results from other code challenges > I thought I would try putting one out there myself. > The goal is to have a routine that increments and keeps track of > time in a BCD format. > Points are scored as follows: > 1 point for each ROM location used. > 3 for each RAM. ; BCD clock code challenge ; WARNING: This code is not tested ; ; The regs must be allocated so that a certain bit is set only for ; the hours, for example: seconds EQU 20 minutes EQU 21 hours EQU 22 #define hoursFlag FSR,1 ClockTick: MOVLW seconds loop: MOVWF FSR INCF INDF,f MOVLW 6 BTFSC hoursFlag MOVLW 11 ADDWF INDF,f BTFSS STATUS,DC SUBWF INDF,f MOVLW 60 BTFSC hoursFlag MOVLW 24 SUBWF INDF,W BTFSS STATUS,C RETURN CLRF INDF INCF FSR,W BTFSS hoursFlag GOTO loop ; This last instruction is not necessary if the code that's executed ; after the routine follows, in that case the "RETURN" of a fwe lines ; above should be a "GOTO..." RETURN IF it works, it is 19 or 20 ROM words long, and uses 3 regs and FSR. That is 31 or 32 points. Regards, Andres Djordjalian mailto:adjordj@aleph.fi.uba.ar *** INDICART Carteles Electronicos Buenos Aires, Argentina *** http://www.indicart.com.ar