中间忙了点别的事……这段代码有段时间了,自己回顾一下也有点问题,还好改完了
assume cs: code,ss:stack
data segment
db 16 dup (0)
data ends
stack segment
db 16 dup (0)
stack ends
code segment
start:
mov ax,317Ah ;12666
mov bx,data
mov ds,bx
mov si,0
mov di,0
call dtoc ; dwords to characters 12666-> 1 2 6 6 6
mov dh,8
mov dl,3
mov cl,2
call show_str ; show strings one the 8 ,3
MOV AH,1 ;调用1号中断,用户任意按键
INT 21H
MOV AH,0AH ;调用0A号中断,读入键盘输入的字符串.
INT 21H
mov ax,4c00h
int 21h
dtoc: ;---------------------------------------------------------dtoc start
mov dx,0
mov di,10
mov bx,0
push bx ;-------------------------make sure 0 is bottom of the stack next get can detect it and end the loop
s00:
div di
mov cx,dx
mov si,0
jcxz nextstep1 ; ------------- if ax --quotient --- is 0
push dx ;Remainder 1 2 6 6 6 0
mov dx,0
jmp short s00
nextstep1: ;--------------------------write to data segment for store
mov ch,0
pop cx
jcxz nextstep2
add cl,30h
mov [si],cl
inc si
jmp short nextstep1
nextstep2: ;-----------------------------clear
mov cx,0
mov di,0
mov si,0
ret ;---------------------------------------------------------dtoc end
show_str:
mov bp,cx
mov cx,0
mov ax,0b800h
mov es,ax
mov cl,dh
s1:
add bx,00a0h
loop s1
mov cl,dl
s2:
add si,2
loop s2
mov cx,0
j1:
mov cx,0
mov ah,0
mov al,ds:[di]
mov cl,al
jcxz over1
mov ah,2h
mov word ptr es:[bx+si],ax
inc di
add si,2h
jmp short j1
over1:
mov cx,bp
ret
code ends
end start
呵呵 就是显示到屏幕上,主要问题再div di 那,本来我写成 div word ptr di,masm编译报错,Illegal use of register ,不晓得了,然后改成 div di 通过了,希望哪个大大给指点一下为什么会这样……继续前进,函数调用 call 有了深入的理解