Visual c++ Inline assembler problem

  • Thread starter Thread starter Lucas
  • Start date Start date
L

Lucas

can sombody tell me why if i create a global variable i
cant acces the OFFSET inside de _asm statment??

i mean:

UCHAR MyVar;

void Main(void)
{

_asm {

mov ebx, offset MyVar //The Error
lea ebx, MyVar //Error again...
}

}

It throw me the error "operand type not correct"...
why??
 
Lucas said:
can sombody tell me why if i create a global variable i
cant acces the OFFSET inside de _asm statment??

i mean:

UCHAR MyVar;

void Main(void)
{

_asm {

mov ebx, offset MyVar //The Error
lea ebx, MyVar //Error again...
}

}

It throw me the error "operand type not correct"...
why??

Because ebx is a 32-bit register and (I assume) MyVar is an unsigned 8-bit
character. Try:

__asm
{
mov bl,MyVar
}

if you want the value of MyVar.

If you want the address of MyVar, you could use:

__asm
{
lea ebx,[MyVar]
}

Brian Gladman
 
Back
Top