|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我还是弄不明白,为什么现在用到栈不再去设定sp指针的位置,push和pop的那样随意,会出现覆盖或溢出的问题嘛
- assume cs:code , ds:data
- data segment
- dw 16 dup (0)
- data ends
- code segment
- start:mov ax,12666
- mov bx,data
- mov ds,bx
- mov si,0
- call dtoc
- mov dh,8
- mov dl,3
- mov cl,44
- call show
- mov ax,4c00h
- int 21h
- dtoc:push dx
- push cx
- push ax
- push si
- push bx
- mov bx,0
- s1:mov cx,10d
- mov dx,0
- div cx
- mov cx,ax
- jcxz s2
- add dx,30h
- push dx
- inc bx
- jmp short s1
- s2:add dx,30h
- push dx
- inc bx
- mov cx,bx
- mov si,0
- s3:pop ax
- mov [si],al
- inc si
- loop s3
- pop bx
- pop si
- pop ax
- pop cx
- pop dx
- ret
- show:push cx
- push si
- mov ax,0b800h
- mov es,ax
- mov ax,0
- mov al,0a0h
- mul dh
- mov di,ax
- mov al,2
- mul dl
- sub ax,2
- add di,ax
- mov bx,0
- mov al,cl
- mov ch,0
-
- s:mov cl,ds:[si]
- jcxz ok
- mov es:[di+bx],cl
- mov es:[di+bx+1],al
- inc si
- add di,2
- jmp short s
-
- ok: pop si
- pop cx
- ret
- code ends
- end start
复制代码 |
|