Daniel Troy wrote:
DT> can anyone improve my rather shitty and long algorythm to convert hex
DT> into decimal???
I didn't go over your code, but maybe the following will help:
;---------------------------------------------------------------------------
;write value in AX as decimal
;all registers except AX are preserved
;---------------------------------------------------------------------------
write_dec proc
push bx ;
push cx ;save registers
push dx ;
mov cx,0 ;will keep digit count in cx
mov bx,10 ;convert to decimal by dividing by 10
w1:
xor dx,dx
div bx ;divide by 10--store remainder(=last
decimal
push dx ;digit) on stack
inc cx ;digit-count in cx
or ax,ax ;
jnz w1 ;repeat if quotient non-zero
mov bh,0 ;bh = display-page
w2:
pop ax ;pop digits off stack and output to screen
add al,30h ;(remember cx = number of digits)
mov ah,0eh ;
int 10h ;
loop w2 ;
pop dx
pop cx
pop bx
ret
write_dec endp
--- Maximus/2 3.01
---------------
* Origin: Madman BBS * Chico, California * 916-893-8079 * (1:119/88)
|