I am trying to write inline assembly in a C file and I get 2 errors :
open.c:10: Error: junkptr nombre’ after expression`
open.c:10: Error: suffix or operands invalid forles’`
This is my file :
int open(char * nombre, unsigned char modo)
{
int retval;
int nrllamada = 6;
asm("mov $8,%%ah \n\t"
"les %%bx, dword ptr nombre \n\t"
"int $0x22 \n\t"
"mov %%eax,%0 \n\t"
: "=r"(retval)
: "a"(modo)
);
return retval;
}
The correct way to write in registers ES and BX the 32 bits pointer named nombre is to connect the C variable nombre to register ECX, move the lower 16 bits of ECX to register BX, rotate the ECX register 16 bits so the lower 16 bits goes to the higher 16 bits of the same register and vice versa and finally move the lower 16 bits of ECX to ES.