【发布时间】:2014-02-22 01:35:21
【问题描述】:
所以我正在学习 intel x86 汇编,我正在尝试向用户查询两个整数,同时拒绝他们输入小于 0 的整数。虽然我一直遇到分段错误,但不知道为什么。
;.........................................................
;.........................................................
; sub-program to read an integer
segment .Data
readmsg db "Enter two positive integers:", 0
negative_msg db "No, enter a POSITIVE integer.", 0
segment .text
int_cin:
push ebp
mov ebp,esp
mov ecx, 2
mov eax, readmsg
call print_string
start:
call read_int
mov ebx, eax
cmp ebx, 0
jge skip
mov eax, negative_msg
call print_string
call print_nl
loop start
skip:
push ebx
dec ecx
loop start
pop ebx
mov [Sec_Int], ebx
pop ebx
mov [First_Int], ebx
pop ebp
ret
【问题讨论】:
标签: assembly segmentation-fault