linux64 编译32位扩展汇编

修改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

猜你喜欢

转载自blog.csdn.net/weixin_39849839/article/details/111940518