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