注册 登录
编程论坛 汇编论坛

[讨论] 为什么我的程序运行后什么都没有,没显示数字?

wchx215 发布于 2006-11-04 23:05, 834 次点击

为什么我的程序运行后什么都没有,没显示数字?
stack1 segment
dw 20h dup(0)
stack1 ends
code segment
assume cs:code,ss:stack1
start:mov ax,stack1
mov ss,ax
mov sp,64
mov ax,0f000h
mov ds,ax
mov si,0
mov cx,200
mov ax,0
clc
s: add al,[si]
adc ah,0
inc si
loop s
mov dx,0
call divdw ;求每位数
call newline
mov ax,0
mov dx,0
mov cx,100
clc
mov si,0
s1: add ax,[si]
adc dx,0
inc si
inc si
loop s1
call divdw
mov ax,4c00h
int 21h

divdw proc ;除法,防止溢出
push cx
push bx
push di
mov di,0
divdw1: mov bx,ax
mov ax,dx
mov dx,0
mov cx,10
div cx
push ax ;存放高位商
mov ax,bx
div cx
mov cx,dx
pop dx
push cx
inc di
add dx,ax
jz show
jmp divdw1
show: mov cx,di
show1: pop dx
add dl,30h
mov ah,02h
int 21h
loop show1
pop di
pop bx
pop cx
ret
divdw endp

newline proc ;换行
push dx
push ax
mov dl,0dh
mov ah,02h
int 21h
mov dl,0ah
mov ah,02h
int 21h
pop ax
pop dx
ret
newline endp

code ends
end start

3 回复
#2
wchx2152006-11-05 00:08
终于明白问题出在哪里了,原来是算法的一点错导致堆栈溢出!我已经调试出来了!
#3
dear2006-11-10 10:37
   楼主不厚道啊,有问题了提问,找出问题了,为什么不大家分享呢
#4
wchx2152006-11-10 23:34
呵呵!只是小错误呀!如果你找出错误,那是一种更好的学习哦!
我也不知该说些什么,如果有兴趣可以和我讨论!!!
1