Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 装配AT&;T x86从文件中读取_C_Assembly_Att - Fatal编程技术网

C 装配AT&;T x86从文件中读取

C 装配AT&;T x86从文件中读取,c,assembly,att,C,Assembly,Att,我正在尝试编写一段代码来显示txt文件的内容。新文件中只存储了数字,每行一个数字(%d\n)。当前代码如下所示: movl $0 , 320(%ebp) #a pre reserved location on the stack for the first number that needs to be cleared first leal 320(%ebp), %eax #a pre-chosen location for the memory push %eax push $d

我正在尝试编写一段代码来显示txt文件的内容。新文件中只存储了数字,每行一个数字(%d\n)。当前代码如下所示:

movl $0 , 320(%ebp)
#a pre reserved location on the stack for the first number that needs to be cleared first  
leal 320(%ebp), %eax    #a pre-chosen location for the memory 
push %eax 
push $dataformat        # . asciz "%d \n"
push %ebx               #the result from the fopen is stored in ebx 
call _fscanf
push 320(%ebp)
push %dataformat
call _printf 

但是,除非我将movl$0更改为其他值,否则结果仍然为0。

问题解决后,发现%ebx中的文件处于附加模式而不是写入模式

,问题是..?如何使其不打印0,而是打印所需的值。为什么要调用
fscanf
两次,而不是第二次推送文件句柄?你的意思是调用
printf
?Yhea我手动输入了它,因为它来自的计算机没有访问堆栈溢出的权限。当你在堆栈上按下
ebx
时,你确定
ebx
包含有效的文件句柄吗?而且文件的行与
“%d\n”
完全匹配(可能文件中的行尾稍有不同)。您确实应该检查您调用的函数的返回值。