I'm trying to make commands that return time and date in a 16 bit real mode OS. When I read from the RTC, however, some wierd values are returned. According to the RTC, there seems to be 90 seconds per minute and 90 minutes per hour.
Below, you see a snippet of code which should print between 0 and 59 seconds, but prints between 0 and 89:
get_seconds:
xor ax, ax ; clear AX
mov al, 0x00 ; get seconds
out 0x70, al ; set index
in al, 0x71 ; load index to AL
call print_decimal ; print contents of AX as decimal
print_decimal:
lea si, [decimal_str+9] ; point SI to last byte in buffer
mov cx, 10 ; 10 = divisor for base 10 printing
.loop
xor dx, dx ; clear DX
div cx ; AX = AX / 10, remainder in DX
add dl, '0' ; convert remainder to ASCII
dec si ; store digits from right to left
mov [si], dl ; store remainder as ASCII in the buffer
test ax,ax ; check if AX = 0
jz .print ; if AX = 0, print decimal-string
jmp .loop
.print
mov bx, si ; set BX to last stored ASCII-digit
call print_string ; regular int 10h string printer
.done
ret
decimal_str: times 10 db 0 ; buffer