【发布时间】:2015-01-31 11:05:01
【问题描述】:
我是 X86 汇编语言的初学者。我知道如何使用内置函数从标准输入读取并写入标准输出,但我不确定如何使用纯汇编代码(即操作寄存器和利用系统调用)来做到这一点。
#include <stdio.h>
#include <unistd.h>
int main(){ /* copy input to output */
char buf[BUFSIZ];
int n;
while ((n = read(0, buf, BUFSIZ)) > 0)
write(1, buf, n);
return 0;
}
这是我编写的 C 代码,首先从标准输入读取(由数字 0 表示),然后写入标准输出(由数字 1 表示)。谁能帮我把它转换成普通的汇编代码(请不要“调用读取”和“调用写入”)?
语法无关紧要,但首选 32 位 AT&T,因为我一直在使用它:) 提前致谢!
【问题讨论】:
标签: x86 stdout stdin system-calls att