linux64 编译32位扩展汇编

修改test.c

#include
void main() {
int ret_cnt = 0, test = 0;
char* fmt = “hello,world\n”; // 共 12 个字符
asm(".code32;pushl %1;
call printf;
addl $4, %%esp;
movl $6, %2"
:"=a"(ret_cnt)
:“m”(fmt),“r”(test)
);
printf(“the number of bytes written is %d\n”, ret_cnt);
}#

安装 32位环境

sudo apt-get install gcc-multilib g++-multilib

编译

gcc -o test test.c -m32

你可能感兴趣的:(LINUX)