3 回答

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊
你有嘗試過嗎?
gcc -S -masm=intel test.c
未經(jīng)測試,但我在這個(gè)論壇上找到了它,有人聲稱它為他們工作。
我只是在Mac上嘗試過,但失敗了,因此我在手冊頁中進(jìn)行了查找:
-masm=dialect
Output asm instructions using selected dialect. Supported choices
are intel or att (the default one). Darwin does not support intel.
它可能在您的平臺上運(yùn)行。
對于Mac OSX:
clang++ -S -mllvm --x86-asm-syntax=intel test.cpp

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊
的
gcc -S -masm=intel test.c
和我一起工作。但是我可以說另一種方式,盡管這與運(yùn)行g(shù)cc無關(guān)。編譯可執(zhí)行文件或目標(biāo)代碼文件,然后使用objdump以Intel asm語法反匯編目標(biāo)代碼,如下所示:
objdump -d --disassembler-options=intel a.out
這可能會有所幫助。

TA貢獻(xiàn)1833條經(jīng)驗(yàn) 獲得超4個(gè)贊
我在CPP文件中有以下代碼:
#include <conio.h>
#include <stdio.h>
#include <windows.h>
int a = 0;
int main(int argc, char *argv[]) {
asm("mov eax, 0xFF");
asm("mov _a, eax");
printf("Result of a = %d\n", a);
getch();
return 0;
};
該代碼與此GCC命令行一起工作:
gcc.exe File.cpp -masm=intel -mconsole -o File.exe
它將生成* .exe文件,并且按照我的經(jīng)驗(yàn)可以正常工作。
Notes:
immediate operand must be use _variable in global variabel, not local variable.
example: mov _nLength, eax NOT mov $nLength, eax or mov nLength, eax
A number in hexadecimal format must use at&t syntax, cannot use intel syntax.
example: mov eax, 0xFF -> TRUE, mov eax, 0FFh -> FALSE.
就這樣。
- 3 回答
- 0 關(guān)注
- 981 瀏覽
添加回答
舉報(bào)