Вот содержимое моего 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.