]> git.sur5r.net Git - cc65/commitdiff
Fixed 12 AM/PM handling.
authorOliver Schmidt <ol.sc@web.de>
Fri, 17 Aug 2018 22:13:38 +0000 (00:13 +0200)
committerOliver Schmidt <ol.sc@web.de>
Fri, 17 Aug 2018 23:29:40 +0000 (01:29 +0200)
Midnight is 12 AM and noon is 12 PM (see https://en.wikipedia.org/wiki/12-hour_clock). Therefore we need to subtract 12 hours in exactly those two hours.

libsrc/c128/gettime.s
libsrc/c64/gettime.s
libsrc/cbm510/gettime.s
libsrc/cbm610/gettime.s

index b59789117442d320561b446d69f0257ae9bb2e35..81f49c640621c3845f38f0cf69cacddfc431a5e7 100644 (file)
         jsr     pushax
 
         lda     CIA1_TODHR
-        bpl     AM
-        and     #%01111111
         sed
+        tax                     ; Save PM flag
+        and     #%01111111
+        cmp     #$12            ; 12 AM/PM
+        bcc     @L1
+        sbc     #$12
+@L1:    inx                     ; Get PM flag
+        bpl     @L2
         clc
         adc     #$12
-        cld
-AM:     jsr     BCD2dec
+@L2:    cld
+        jsr     BCD2dec
         sta     TM + tm::tm_hour
         lda     CIA1_TODMIN
         jsr     BCD2dec
index 61c5115ae25bdc18be1b2957dd7a8fffa67a7d8a..8973e0e33fe89e3362c3dcd2a877d10c040b0dab 100644 (file)
         jsr     pushax
 
         lda     CIA1_TODHR
-        bpl     AM
-        and     #%01111111
         sed
+        tax                     ; Save PM flag
+        and     #%01111111
+        cmp     #$12            ; 12 AM/PM
+        bcc     @L1
+        sbc     #$12
+@L1:    inx                     ; Get PM flag
+        bpl     @L2
         clc
         adc     #$12
-        cld
-AM:     jsr     BCD2dec
+@L2:    cld
+        jsr     BCD2dec
         sta     TM + tm::tm_hour
         lda     CIA1_TODMIN
         jsr     BCD2dec
index 3ad162e3ba48064eb4cce7468322deafb19ba1d3..b89b9b16b2a6c9f642fb638adaac0ed4b5a483e7 100644 (file)
 
         ldy     #CIA::TODHR
         lda     (cia2),y
-        bpl     AM
-        and     #%01111111
         sed
+        tax                     ; Save PM flag
+        and     #%01111111
+        cmp     #$12            ; 12 AM/PM
+        bcc     @L1
+        sbc     #$12
+@L1:    inx                     ; Get PM flag
+        bpl     @L2
         clc
         adc     #$12
-        cld
-AM:     jsr     BCD2dec
+@L2:    cld
+        jsr     BCD2dec
         sta     TM + tm::tm_hour
         ldy     #CIA::TODMIN
         lda     (cia2),y
index 30226213d2df163c7afb059bac4179044cefa785..cfd2a9fe93c5e71b7ffb1c3ebfb600acd48160fb 100644 (file)
 
         ldy     #CIA::TODHR
         lda     (cia),y
-        bpl     AM
-        and     #%01111111
         sed
+        tax                     ; Save PM flag
+        and     #%01111111
+        cmp     #$12            ; 12 AM/PM
+        bcc     @L1
+        sbc     #$12
+@L1:    inx                     ; Get PM flag
+        bpl     @L2
         clc
         adc     #$12
-        cld
-AM:     jsr     BCD2dec
+@L2:    cld
+        jsr     BCD2dec
         sta     TM + tm::tm_hour
         ldy     #CIA::TODMIN
         lda     (cia),y