【发布时间】:2016-07-07 12:40:23
【问题描述】:
我正在学习如何使用 masm32 中的程序,所以我编写了写一个数字的程序:
.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,分段错误。”。我该怎么办?
【问题讨论】:
-
您的堆栈不平衡。你想删除你推送的
number。
标签: assembly segmentation-fault masm32