Page 1 of 1

time clock

Posted: Sun Dec 01, 2002 12:00 am
by feaster
It's maybe a stupid question but i can't find the answer at this moment.

I want to make a clock in assembler(without using an Interupt), but it won't work fine.

I've got this as so far !
[code]
xor al,al           ; seconds function
out 0x70,al
xor ax,ax
in  al,0x71
[/code]

If i put al on the screen i get an ascii charter.

I don't know how to convert it to a DEC nr without a compare list.
(fast example)
char1 db "$"
chartertoprint db 0x00
cmp al,char
je .blablabla

.blablabla
mov chartertoprint,9  ;DEC 9

This is to much code for doing it so is there a faster way ?

RE:time clock

Posted: Mon Dec 02, 2002 12:00 am
by eox
did you get a bcd value in al? don't remember, too long ago.. but it must be..
so try something like this:

lut db "0123456789",0,0,0,0,0,0  ; 0,0,.. not needed if you trust your rtc
                                 ; it could erroneously return 0xfc for example

mov ecx,eax
and eax,0x0f
and ecx,0xf0
shr ecx,4
mov bl,[lut+eax]
mov bh,[lut+ecx]

done.. if you have a 0x59 in al you get bl = 9 and bh = 5