|
1鱼币
assume cs:code
data segment
dw 123,12666,1,8,3,38
db 100 dup (0)
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,02
mov bp,0
mov si,0
mov bx,0
mov ax,0
call show_str
mov ax,4c00h
int 21h
dtoc: mov cx,6 ;cx=6,数据除以十得到余数
s: push cx ;cx将保存栈段
s2: mov ax,[si] ;取得data段的被除数
push si
s3: mov cx,ax ;判断商为零
jcxz okye
mov bx,10 ;bx=10
mov dx,0 ;dx清零,继续一个数的下一
div bx
add dx,30h ;余数加上30h,改变为ASCII码
push dx ;得到的ASCII码放入栈中
inc di
jmp short s3 ;商不为零,继续转移到s2
okye: mov cx,di
s4: pop dx ;得到的ASCII码值放入ds:si
mov [bp+12],dx ;[si+12]=dx
inc bp
loop s4
mov di,0
mov dx,0
pop si
add si,2
pop cx
loop s
ret
show_str:mov ax,0A0h
dec dh
mul dh
mov bx,ax
mov ax,2
mul dl
sub ax,2
add bx,ax
mov ax,0B800h
mov es,ax
mov si,12
mov al,cl
mov ah,0
t: mov cl,ds:[si]
mov ch,0
jcxz ok
mov es:[bx+di],cl
mov es:[bx+di+1],al
add di,2
add si,1
jmp short t
ok: ret
code ends
end start
|
|