제 CPP 파일 내용은 이렇습니다:
#include <conio.h>
#include <stdio.h>
#include <windows.h>
int result = 0;
int main(int count, char *items[]) {
asm("mov eax, 0xEE");
asm("mov _result, eax");
printf("result contains %d\n", result);
getch();
return 0;
};
이 GCC 명령으로 저 코드를 동작시켰어요:
gcc.exe Sample.cpp -masm=intel -mconsole -o Sample.exe
결과로 *.exe 파일이 나오고, 제 경우에는 잘 실행됐어요.
Remarks:
for an immediate operand, use _variable for a global variable rather than a local one.
exampel: mov _itemCount, eax NOT mov $itemCount, eax or mov itemCount, eax
Hexadecimal numbers require at&t notation instead of intel notation.
example: mov eax, 0xEE -> TRUE, mov eax, 0EEh -> FALSE.
이상입니다.
영어에서 번역·원문 보기Here's what my CPP file contains:
#include <conio.h>
#include <stdio.h>
#include <windows.h>
int result = 0;
int main(int count, char *items[]) {
asm("mov eax, 0xEE");
asm("mov _result, eax");
printf("result contains %d\n", result);
getch();
return 0;
};
I got that code working using this GCC invocation:
gcc.exe Sample.cpp -masm=intel -mconsole -o Sample.exe
The output is an *.exe file, which ran successfully for me.
Remarks:
for an immediate operand, use _variable for a global variable rather than a local one.
exampel: mov _itemCount, eax NOT mov $itemCount, eax or mov itemCount, eax
Hexadecimal numbers require at&t notation instead of intel notation.
example: mov eax, 0xEE -> TRUE, mov eax, 0EEh -> FALSE.
Nothing more.