¿Cómo se utiliza gcc para generar código ensamblador en sintaxis Intel?
La opción gcc -S
generará código ensamblador en la sintaxis de AT&T, ¿hay alguna forma de generar archivos en la sintaxis de Intel? O hay una manera de convertir entre los dos?
3 answers
¿has probado esto?
gcc -S -masm=intel test.c
No probado, pero lo encontré en este foro donde alguien afirmó que funcionaba para ellos.
Acabo de probar esto en el mac y falló, así que miré en mi página de manual:
-masm=dialect
Output asm instructions using selected dialect. Supported choices
are intel or att (the default one). Darwin does not support intel.
Puede funcionar en su plataforma.
Para Mac OSX:
clang++ -S -mllvm --x86-asm-syntax=intel test.cpp
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:34:21
El
gcc -S -masm=intel test.c
Funciona conmigo. Pero puedo decir otra manera, aunque esto no tiene nada que ver con el funcionamiento de gcc. Compile el ejecutable o el archivo de código objeto y luego desmonte el código objeto en la sintaxis de Intel asm con objdump como se muestra a continuación:
objdump -d --disassembler-options=intel a.out
Esto podría ayudar.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-04-12 16:50:18
Tengo este código en el archivo 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;
};
Ese código funcionó con esta línea de comandos de GCC:
gcc.exe File.cpp -masm=intel -mconsole -o File.exe
Resultará *.archivo exe, y funcionó en mi experiencia.
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.
Eso es todo.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-21 05:55:14