linux64 编译32位扩展汇编
程序员文章站
2022-06-29 10:18:53
...
修改test.c
#include <stdio.h>
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
推荐阅读