我正在学习如何在MASM32程序工作,所以我写的过程,写一个数字:SIGSEGV,分割过错而做“RET”
.386
.model flat, stdcall
option casemap : none
include \masm32\include\masm32.inc
include \masm32\include\kernel32.inc
include \masm32\macros\macros.asm
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\kernel32.lib
.data
number dw 397
temp db 10
symbol dw ?
i dw ?
.code
printnumber proc num:WORD
mov ecx, 0
mov ax, num
@@:
mov edx, 0
div temp
mov bh, 0
mov bl, ah
push bx
inc cx
cmp al, 0
mov bl, al
mov ax, bx
jnz @B
mov i, cx
@@:
pop symbol
add symbol, 48
mov ax, symbol
print ADDR symbol
dec i
cmp i, 0
jnz @B
ret
printnumber endp
start:
push number
call printnumber
ret ;here program fails
end start
程序打印“397”成功,但尝试后做“ret”有个问题:“程序收到信号SIGSEGV,分段错误。”。我该怎么办?
你有不平衡的堆栈。你想删除你推送的'号码'。 – Jester