參考資訊:
https://cboard.cprogramming.com/cplusplus-programming/122654-inline-asm-mingw.html
問題如下:
/tmp/ccOFcofP.s: Assembler messages: /tmp/ccOFcofP.s:18: Error: junk `(%esp)' after expression /tmp/ccOFcofP.s:19: Error: junk `(%esp)' after expression /tmp/ccOFcofP.s:20: Error: junk `(%esp)' after expression /tmp/ccOFcofP.s:21: Error: junk `(%esp)' after expression /tmp/ccOFcofP.s:22: Error: no such instruction: `movl $LC0,8(%esp)' /tmp/ccOFcofP.s:23: Error: no such instruction: `imull %edx,%eax' /tmp/ccOFcofP.s:24: Error: junk `(%esp)' after expression /tmp/ccOFcofP.s:25: Error: junk `(%esp)' after expression /tmp/ccOFcofP.s:26: Error: no such instruction: `movl %eax,12(%esp)' /tmp/ccOFcofP.s:27: Error: no such instruction: `popl %edx'
修改前
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int _main(int argc, char**argv)
{
volatile char a, b, c;
__asm__(
".intel_syntax noprefix\n"
"push ax\n"
);
a = 8;
b = 9;
c = a * b;
printf("%d\n", c);
}
修改後
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int _main(int argc, char**argv)
{
volatile char a, b, c;
__asm__(
".intel_syntax noprefix\n"
"push ax\n"
".att_syntax\n"
);
a = 8;
b = 9;
c = a * b;
printf("%d\n", c);
}