반응형
gcc를 사용하여 인텔 구문으로 어셈블리 코드를 생성하는 방법은 무엇입니까?
이 gcc -S
옵션은 AT & T 구문으로 어셈블리 코드를 생성합니다. 인텔 구문으로 파일을 생성하는 방법이 있습니까? 아니면 둘 사이를 변환하는 방법이 있습니까?
이것을 시도 했습니까?
gcc -S -masm=intel test.c
테스트를 거치지 않았지만 누군가가 그것을 위해 일한다고 주장한 이 포럼 에서 찾았 습니다.
방금 Mac에서 이것을 시도했지만 실패 했으므로 맨 페이지를 보았습니다.
-masm=dialect
Output asm instructions using selected dialect. Supported choices
are intel or att (the default one). Darwin does not support intel.
플랫폼에서 작동 할 수 있습니다.
Mac OSX의 경우 :
clang++ -S -mllvm --x86-asm-syntax=intel test.cpp
출처 : https://stackoverflow.com/a/11957826/950427
그만큼
gcc -S -masm=intel test.c
나와 함께 작동합니까? 그러나 이것은 다른 방법으로 말할 수 있지만 gcc를 실행하는 것과는 아무런 관련이 없습니다. 실행 파일 또는 객체 코드 파일을 컴파일 한 후 다음과 같이 objdump를 사용하여 Intel asm 구문으로 객체 코드를 디스 어셈블하십시오.
objdump -d --disassembler-options=intel a.out
도움이 될 수 있습니다.
이 코드는 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, eax
A number in hexadecimal format must use at&t syntax, cannot use intel syntax.
example: mov eax, 0xFF -> TRUE, mov eax, 0FFh -> FALSE.
그게 다야.
반응형
'development' 카테고리의 다른 글
언제 Serializable 인터페이스를 구현해야합니까? (0) | 2020.06.19 |
---|---|
HTTP 리디렉션 코드의 차이점 (0) | 2020.06.19 |
자식에서 다른 분기로 전환하려면 어떻게해야합니까? (0) | 2020.06.19 |
멤버 함수를 조건부로 컴파일하기위한 std :: enable_if (0) | 2020.06.19 |
Eclipse에서 RemoteSystemsTempFiles 란 무엇입니까? (0) | 2020.06.19 |