Open ClaudioDaffra opened 4 years ago
That's.... really interesting! Under the hood it's just passing it on to GCC so I doubt I can fix it. My guess at what's happening is it thinks abx
as a variable or macro or something and evaluates to 0. Or you might've found a bug in the gcc assembler.
I have done some tests
gcc prova.c -o prova.exe -masm=intel
but compiler gives me right error message :
C:\Users\DAFFRA~1\AppData\Local\Temp\cc8IvaME.o:prova.c:(.text+0x1d):
undefined reference to `abx'
collect2.exe: error: ld returned 1 exit status
gcc version 4.9.2 (i686-posix-sjlj, built by strawberryperl.com project)
#include <stdio.h>
int main ( void )
{
int src = 1;
int dst;
asm ("add al , byte ptr [abx+edi*2]\n\t"
: "=r" (dst)
: "r" (src)
);
printf("%d\n", dst);
return 0 ;
}
when i enter this assembly code :
add eax , byte ptr [abx+edi*2]
assember generates the following code
Assembly Raw Hex (zero bytes in bold):
02047D00000000
String Literal:
"\x02\x04\x7D\x00\x00\x00\x00"
Array Literal:
{ 0x02, 0x04, 0x7D, 0x00, 0x00, 0x00, 0x00 }
Disassembly: 0: 02 04 7d 00 00 00 00 add al,BYTE PTR [edi*2+0x0]