Skip to main content
deleted 16 characters in body; added 4 characters in body; added 4 characters in body; deleted 4 characters in body; added 11 characters in body; deleted 65 characters in body
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57

Thought it would be a more straightforward use of BCD operations, though the ASCII to binary and back conversions ate a lot of bytes. BUT it gave me a use for the AAA instruction so there's that.

21 bytes if I could take I/O as a packed BCD hex word (12:59 == 0x1259).

PLUS I'd, and get to use AAA's bastard step-sibling DAA to do it!

40          INC  AX             ; increment the time 
27          DAA                 ; decimal adjust packed BCD 
3C 60       CMP  AL, 60H        ; did minutes reach 60? 
7C 0E       JL   DONE           ; if not, do nothing else 
32 C0       XOR  AL, AL         ; otherwise, reset minutes to 0 
86 E0       XCHG AH, AL         ; swap hours and minutes in AL 
40          INC  AX             ; increment the hours 
27          DAA                 ; decimal adjust packed BCD 
3C 24       CMP  AL, 24H        ; did hours reach 24? 
86 E0       XCHG AH, AL         ; real quick, swap hours and minutes back 
7C 02       JL   DONE           ; if less than 24, do nothing eleelse 
32 E4       XOR  AH, AH         ; otherwise, reset hour to 0 
        DONE: 
C3          RET

Thought it would be a more straightforward use of BCD operations, though the ASCII to binary and back conversions ate a lot of bytes. BUT it gave me a use for the AAA instruction so there's that.

21 bytes if I could take I/O as a packed hex word (12:59 == 0x1259).

PLUS I'd get to use AAA's bastard step-sibling DAA to do it!

40          INC  AX             ; increment the time 
27          DAA                 ; decimal adjust packed BCD 
3C 60       CMP  AL, 60H        ; did minutes reach 60? 
7C 0E       JL   DONE           ; if not, do nothing else 
32 C0       XOR  AL, AL         ; otherwise, reset minutes to 0 
86 E0       XCHG AH, AL         ; swap hours and minutes in AL 
40          INC  AX             ; increment the hours 
27          DAA                 ; decimal adjust packed BCD 
3C 24       CMP  AL, 24H        ; did hours reach 24? 
86 E0       XCHG AH, AL         ; real quick, swap hours and minutes back 
7C 02       JL   DONE           ; if less than 24, do nothing ele 
32 E4       XOR  AH, AH         ; reset hour to 0 
        DONE: 
C3          RET

Thought it would be a more straightforward use of BCD operations, though it gave me a use for the AAA instruction so there's that.

21 bytes if I could take I/O as a packed BCD hex word (12:59 == 0x1259), and get to use AAA's bastard step-sibling DAA!

40          INC  AX             ; increment the time 
27          DAA                 ; decimal adjust packed BCD 
3C 60       CMP  AL, 60H        ; did minutes reach 60? 
7C 0E       JL   DONE           ; if not, do nothing else 
32 C0       XOR  AL, AL         ; otherwise, reset minutes to 0 
86 E0       XCHG AH, AL         ; swap hours and minutes in AL 
40          INC  AX             ; increment the hours 
27          DAA                 ; decimal adjust packed BCD 
3C 24       CMP  AL, 24H        ; did hours reach 24? 
86 E0       XCHG AH, AL         ; real quick, swap hours and minutes back 
7C 02       JL   DONE           ; if less than 24, do nothing else 
32 E4       XOR  AH, AH         ; otherwise, reset hour to 0 
        DONE: 
C3          RET
who am I kidding
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57

Thought it would be a more straightforward use of BCD operations, though the ASCII to binary and back conversions ate a lot of bytes. BUT it gave me a use for the AAA instruction so there's that. Operating purely on the ASCII values directly might be the shorter way to go, so perhaps that's worth exploring later...

Thought it would be a more straightforward use of BCD operations, though the ASCII to binary and back conversions ate a lot of bytes. BUT it gave me a use for the AAA instruction so there's that. Operating purely on the ASCII values directly might be the shorter way to go, so perhaps that's worth exploring later...

Thought it would be a more straightforward use of BCD operations, though the ASCII to binary and back conversions ate a lot of bytes. BUT it gave me a use for the AAA instruction so there's that.

add evil DAA version
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57

OR...

21 bytes if I could take I/O as a packed hex word (12:59 == 0x1259).

PLUS I'd get to use AAA's bastard step-sibling DAA to do it!

40          INC  AX             ; increment the time 
27          DAA                 ; decimal adjust packed BCD 
3C 60       CMP  AL, 60H        ; did minutes reach 60? 
7C 0E       JL   DONE           ; if not, do nothing else 
32 C0       XOR  AL, AL         ; otherwise, reset minutes to 0 
86 E0       XCHG AH, AL         ; swap hours and minutes in AL 
40          INC  AX             ; increment the hours 
27          DAA                 ; decimal adjust packed BCD 
3C 24       CMP  AL, 24H        ; did hours reach 24? 
86 E0       XCHG AH, AL         ; real quick, swap hours and minutes back 
7C 02       JL   DONE           ; if less than 24, do nothing ele 
32 E4       XOR  AH, AH         ; reset hour to 0 
        DONE: 
C3          RET

OR...

21 bytes if I could take I/O as a packed hex word (12:59 == 0x1259).

PLUS I'd get to use AAA's bastard step-sibling DAA to do it!

40          INC  AX             ; increment the time 
27          DAA                 ; decimal adjust packed BCD 
3C 60       CMP  AL, 60H        ; did minutes reach 60? 
7C 0E       JL   DONE           ; if not, do nothing else 
32 C0       XOR  AL, AL         ; otherwise, reset minutes to 0 
86 E0       XCHG AH, AL         ; swap hours and minutes in AL 
40          INC  AX             ; increment the hours 
27          DAA                 ; decimal adjust packed BCD 
3C 24       CMP  AL, 24H        ; did hours reach 24? 
86 E0       XCHG AH, AL         ; real quick, swap hours and minutes back 
7C 02       JL   DONE           ; if less than 24, do nothing ele 
32 E4       XOR  AH, AH         ; reset hour to 0 
        DONE: 
C3          RET
-1 byte, low digit on minutes will already be 0 for rollover
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57
Loading
-6 bytes, turns out AAA can operate on ASCII... sort of...
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57
Loading
24:00 fix...
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57
Loading
Post Undeleted by 640KB
24:00 fix...
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57
Loading
Post Deleted by 640KB
Source Link
640KB
  • 11.9k
  • 2
  • 35
  • 57
Loading