linux 64コンパイル32ビット拡張アセンブリ

576 ワード

testを変更します.c
#include void main(){int ret_cnt=0,test=0;char*fmt="hello,world";//計12文字asm(".code 32;pushl%1;call printf;addl$4,%%esp;movl$6,%2":"=a"(ret_cnt):"m"(fmt)、"r"(test);printf("the number of bytes writen is%%d",ret_cnt);}#
32ビット環境のインストール
sudo apt-get install gcc-multilib g++-multilib

コンパイル
gcc -o test test.c -m32