Count Seconds, Minutes, and Hours by Andrew Warren
SECONDS EQU [any register, on any page] MINUTES EQU SECONDS+1 HOURS EQU MINUTES+1 TICK: MOVLW SECONDS ;First, initialize the FSR to point MOVWF FSR ; at SECONDS. CALL SUB1 ;Use the BCD-increment code to inc CALL SUB0 ; SECONDS and then MINUTES. CALL SUB0 ;Call it one last time to increment ; HOURS. GOTO SUB2 ;Keep HOURS in the range [0-23]. SUB0: INCF FSR ;You enter here to point to the next SKPNC ; register before incrementing it. SUB1: INCF INDF ;Or enter here to just increment the ; register. MOVLW 6 ;Use this MOVLW/ADDWF to see whether ADDWF INDF ; reg is outside the range [0-9]. SKPDC ;Obscure DC flag usage was contributed SUBWF INDF ; by Scott Dattalo. MOVLW 0100H - 060H ;Load W with a value that'll make the SUB2: ADDWF INDF,W ; ADDWF overflow if the reg > 60. SKPNC ;If there's an overflow, clear the CLRF INDF ; register. RETLW 0100H - 024H ;Now return with W holding a value that ; will make ADDWF overflow if reg>24.
file: /Techref/microchip/countsecminhrs-aw.htm, 1KB, , updated: 2010/3/26 14:52, local time: 2024/12/30 13:47,
52.15.190.187:LOG IN
|
©2024 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://techref.massmind.org/Techref/microchip/countsecminhrs-aw.htm"> PIC Microcontoller Time Method: Count Seconds, Minutes, and Hours by Andrew Warren</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.