潇潇雨雨
我在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文件,并且按照我的经验可以正常工作。Notes:immediate operand must be use _variable in global variabel, not local variable.example: mov _nLength, eax NOT mov $nLength, eax or mov nLength, eaxA number in hexadecimal format must use at&t syntax, cannot use intel syntax.example: mov eax, 0xFF -> TRUE, mov eax, 0FFh -> FALSE.就这样。