【发布时间】:2018-12-25 13:12:35
【问题描述】:
我尝试使用内联 NASM 在 stdout 中编写一个 char[](注意添加了 .intel_syntax 和 .att_syntax,以便可以使用 gcc 编译)
但它不会在标准输出中写入任何内容。
我在虚拟机上使用 Linux 16 (x86)
是 char c[] 的原因吗? (我通过这种编译方式读到我们不能使用内存变量,而是该怎么做?)
#include<stdio.h>
char c[] = "abcd";
int main(){
asm (".intel_syntax noprefix");
// write c into stdout
asm("mov EAX,4"); // 4: write
asm("mov EBX,1"); // 1: stdout
asm("mov ECX,c");
asm("mov EDX,5");
asm("int 0x80");
// exit program
asm("mov EAX,1")
asm("int 0x80")
asm (".att_syntax noprefix");
}
输出什么都没有
【问题讨论】:
标签: c assembly inline-assembly