显示 dd123456789
本帖最后由 qwangwei 于 2011-1-20 21:49 编辑assume cs:code
stack segment
dw 100h dup(0)
stack ends
data segment
dd 123456789,0
nstr db 10h dup(0)
data ends
code segment
_showstr:
push bp
mov bp,sp
push cx
push dx
push bx
push si
mov ax,0b800h
mov es,ax
xor ax,ax
mov al,
mov cx,80*2
mul cl
xor dx,dx
mov dl,
add dl,dl
add ax,dx
mov si,ax
mov bx,
mov ah,4
_s_show:
mov al,
cmp al,0
jz _s_over
mov es:,ax
inc bx
inc si
inc si
jmp _s_show
_s_over:
pop si
pop bx
pop dx
pop cx
mov sp,bp
pop bp
retn
div_over:
push bp
mov bp,sp
push di
push si
push bx
push dx
push cx
mov di,
mov si,
add di,10h
ww:
mov ax,
mov dx,0
mov bx,10
div bx
mov ,ax
cmp dx,0
jz ww1
mov ax,
div bx
mov ,ax
mov cx,dx
add cx,48
mov ,cl
dec di
jmp ww
ww1:
mov ax,
cmp ax,0
jz over
mov dx,0
div bx
mov ,ax
mov cx,dx
add cx,48
mov ,cl
dec di
jmp ww
over:
add di,1
mov ax,di
pop cx
pop dx
pop bx
pop si
pop di
mov sp,bp
pop bp
retn
start:
mov ax,stack
mov ss,ax
mov sp,200h
mov ax,data
mov ds,ax
mov ax,0
push ax
mov ax,offset nstr
push ax
call div_over
add sp,4
mov bx,ax
mov ax,0a14h
push ax
mov ax,bx
push ax
call _showstr
add sp,4
mov ax,4c00h
int 21H
code ends
end start 不错
利用了数值最大长度来构造了一个类似堆的倒叙存储结构
add cx,48// 这里尽量使用十六进制
函数的调用上 尽量把 参数的传递等做上注释
可以参考这个 https://www.chinapyg.com/viewthread.php?tid=60857&extra=page%3D2 /:017抢占楼层!再回头看代码!
支持,关注中
http://www.discuz.net/static/image/common/sigline.gif
燃文
页:
[1]