So the RTC (real time clock) sends BCD (binary-coded decimal) to make it easy to display the digits on normal 2digit pairs 7seg.

You want to scramble it back to raw binary.

If the minutes is at 49, in BCD you would get %0100_1001

Code:

' in this example bcd = 49 = %0100_1001
dat
mov temp, bcd ' bcd= two 4 bit nybbles
and bcd, #%1111 ' just keep the lower nybble = 9
and temp, #%11110000 ' just keep the higer nybble = 64
shr temp, #1 ' divide by 2 = 32
add bcd, temp ' add it to new bcd. 32+9 = 41
shr temp, #2 ' divide it by 4 = 8
add bcd, temp ' add it to bcd, the bcd is now 49
... ' continue your regular code here.
bcd long %01001001
temp res 1

## Bookmarks