我有这个代码(having a string of length n, build another of length n-2 as it follows: sir2[i]=(sir[i]+sir[i+1]+sir[1+2])/3
),我不知道它为什么冻结。没有错误,我已经调试了一段时间,但我无法弄清楚问题是否与算法有关。x86程序冻结[tasm]
prints macro number
local decompose, pops
mov bx,10
mov al, number
mov cx,0
decompose: ;pushing digits to the stack
inc cx
mov ah,0
div bl
mov dl,ah ; remainder - last digit
add dx,48 ; to transform it in its char version
push dx
cmp al,0
jnz decompose
pops: ; pop digits off the stack
pop dx
mov ah,2h
int 21h
loop pops
; pretty spacing
mov dl,' '
mov ah,2h
int 21h
endm
data segment para public 'data'
sir db 5, 10, 12, 4, 3
n equ $-sir
sir2 db n-2 dup(0)
data ends
code segment para public 'code'
start proc far
assume cs:code,ds:data
push ds
xor ax,ax
push ax
mov ax,data
mov ds,ax
mov si,0
mov dx,3
mov cx,n
sub cx,2
l1:
mov ah,0
mov al,sir[si]
add al,sir[si+1]
add al,sir[si+2] ;sum of 3 numbers
div dx ;sir2[i]=(sir[i]+sir[i+1]+sir[1+2])/3
mov sir2[si],al
inc si
cmp si,cx
jbe l1
mov si,0
l2:
prints sir2[si]
inc si
loop l2
ret
start endp
code ends
end start
任何人都可以帮忙吗?
你做了什么努力来发现它为什么会冻结,你卡在哪里?换句话说,**你是否调试过你的代码**?这个网站不是一个免费的调试服务,因此,就你的问题而言,最有可能的是,它会脱离主题。 –
是的,我做了+我以为我被困在一个循环,所以我改变它为一个jmp。 –
您在* decompose *例程中清除了CX!将'mov cx,0'改成'mov ah,0' –