ChimpFace9000
Mar 4th, 2001, 02:50 PM
I have a number contained in the variable FileSize, and its a word. How do i print out the decimal equivelent?
Jimbob42
Mar 6th, 2001, 11:05 PM
just keep dividing by 10 and saving dx
then add 48 to turn it into a decimal
eg
printnum:
mov ax,filesize
xor cx,cx ;zero counter
mov bx,10 ;decimal
l1:
xor dx,dx ;prepare for division
div bx
inc cx ;+1 digits
add dl,48 ;convert to ascii digit
or ax,ax ;anything left?
push dx ;save digit
jnz l1 ;get next digit
mov di,seg string ;or: push ds pop es etc
mov es,di
mov di,offset string ;es:di = string
cld
l2:
pop ax ;get digit
stosb ;store it in string
loop l2 ;get next one
xor ax,ax OR mov ax,"$" ;terminate string
stosb
ret