This procedure needs to be added to
your library.Unless you already have it.
It displays the 16-bit values in AX
as a string of binary,octal,decimal
or hexadecimal digets.BX contains a
radix value 2 = binary output,8 =
octal output, 10 = decimal output,
16 = hexadecimal output.
model small,uses near calls.
Input parameters:AX = VALUE,BX = RADIX.
public allinone
.model small
.286
.data
buffer db 16 dup(' ') ;buffer that holds the chars
bufferEnd label byte ;end of buffer
xtable db '0123456789ABCDEF' ;TRANSLATE TABLE
allinone proc
pusha
mov cx,0
mov di,offset bufferEnd
LAB1: mov dx,0 ;clear dividend to zero
div bx ;divide AX by the RADIX
xchg ax,dx ;exchange quotient,remainder
push bx
mov bx,offset xtable ;trans table
xlat ;look up ASCII diget
pop bx
dec di ;back up in buffer
mov [di],al ;move diget into buffer
xchg ax,dx ;swap quotient into AX
inc cx ;diget count
or ax,ax ;quoteint = 0?
jnz LAB1
;Display the buffer using CX as a counter
LAB2: mov ah,2 ;function display
mov dl,[di] ;char to display
int 21h
inc di ;point to next char
loop LAB2
popa
ret
alinone endp
end
your library.Unless you already have it.
It displays the 16-bit values in AX
as a string of binary,octal,decimal
or hexadecimal digets.BX contains a
radix value 2 = binary output,8 =
octal output, 10 = decimal output,
16 = hexadecimal output.
model small,uses near calls.
Input parameters:AX = VALUE,BX = RADIX.
public allinone
.model small
.286
.data
buffer db 16 dup(' ') ;buffer that holds the chars
bufferEnd label byte ;end of buffer
xtable db '0123456789ABCDEF' ;TRANSLATE TABLE
allinone proc
pusha
mov cx,0
mov di,offset bufferEnd
LAB1: mov dx,0 ;clear dividend to zero
div bx ;divide AX by the RADIX
xchg ax,dx ;exchange quotient,remainder
push bx
mov bx,offset xtable ;trans table
xlat ;look up ASCII diget
pop bx
dec di ;back up in buffer
mov [di],al ;move diget into buffer
xchg ax,dx ;swap quotient into AX
inc cx ;diget count
or ax,ax ;quoteint = 0?
jnz LAB1
;Display the buffer using CX as a counter
LAB2: mov ah,2 ;function display
mov dl,[di] ;char to display
int 21h
inc di ;point to next char
loop LAB2
popa
ret
alinone endp
end