把大二进制数转化为十进制数并显示
; 程序名称:big_to_decimal
; 程序功能:把大二进制数转化为十进制数并显示结果
name big_to_decimal
title big_to_decimal.asm
.model tiny
.stack 64
.data
source db 0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,0ffh,7fh
len equ $ - source
res_len equ ((24*len)/10)+1
result db res_len dup(0)
.code
start:
mov ax,@data
mov ds,ax
mov es,ax
ready:
trans_begin:
lea si,source
mov cx,len
add si,cx
dec si
std
mov bp,10
trans_body:
lodsb
mov dl,al ; save al in dl and high carry register is dx
mov dh,0
lea di,result
mov bx,res_len
get_decimals:
mov ah,byte ptr [di] ; it is the same as multiplying 256
mov al,0
add ax,dx ; add to the high carry register
xor dx,dx
div bp
mov byte ptr [di],dl
mov dx,ax
inc di
dec bx
cmp bx,0
ja get_decimals
loop trans_body
display:
lea si,result
mov cx,res_len
add si,cx
dec si
std
disp_items:
lodsb
mov dl,al
add dl,030h
mov ah,2
int 21h
loop disp_items
all_end:
mov ax,4c00h
int 21h
end start
“编译、运行后,得到结果如下:”
09223372036854775807