c - 汇编 AT&T x86 从文件读取

标签 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 $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 中的文件处于追加模式而不是写入模式

关于c - 汇编 AT&T x86 从文件读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17021329/

相关文章:

c - 将char [128]数组写入C中的文件

c - fprintf 中的字符串是错误的数据类型(%s)

c - 字符串数组 C

c - 带数组的 C 结构的内存布局

assembly - 如何启动自制操作系统?

c - ATT 汇编到 C

assembly - 当中断发生时,x86 架构中会发生什么?

linux - x86_64 机器的 GCC 内联汇编的汇编程序错误(at&t 语法)

assembly - x86-64中movq和movabsq之间的区别

c - 汇编与 C 代码比较