为什么此AT&T汇编代码会给出分段错误?

时间:2018-08-08 08:46:28

标签: assembly x86 scanf coredump gas

这是我的第一个汇编源代码,我想使用scanf函数,但是此ELF给出了分段错误。

因此,我尝试解决使用核心转储的问题,但我做不到。

使用scanf函数

.section .data

string: 
.ascii "input yournumber : \0"

value: 
.ascii "your value is %d \n\0"

scanf:
.ascii "%d"

.section .text

.globl _start

_start:

movl %esp, %ebp
subl $4, %esp

pushl $string
call printf

leal -4(%ebp), %ebx
pushl %ebx
pushl $scanf
call scanf

pushl -4(%ebp)
pushl $value
call printf

pushl $0
call exit

0 个答案:

没有答案
相关问题