Visual c++ Inline assembler problem

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??
 
B

Brian Gladman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top