NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on April 01, 2008, 10:27:02 PM
-
Hello
How can i convert bcd numbers to ascii.
Could you tell me some example.
10x
-
Treat 'em like hex!
Best,
Frank
-
coud you give me example
-
Okay... where's your bcd? Ah, here's some! Whatever you're using for "printhex" will do...
Best,
Frank
; print time
; nasm -f bin -o myfile.com myfile.asm
org 100h
mov ah, 2 ; get rtc time
int 1Ah
; hour in ch, minutes in cl, seconds in dh
; all in bcd
mov al, ch
call showalhex
mov al,':'
int 29h
mov al, cl
call showalhex
mov al, ':'
int 29h
mov al, dh
call showalhex
ret
showalhex:
mov ah, al ; make a copy
shr al, 4
call hexnyb
mov al, ah ; restore our value
; fall through
hexnyb:
and al, 0Fh ; isolate low nibble
add al, '0' ; convert to ascii
; this isn't going to happen with bcd!
cmp al, '9'
jna decdig
add al, 7 ; adjust to 'A' - 'F'
decdig:
int 29h
ret