I’m trying to work with inline assembly but I’m receiving errors..
Here’s a part of the code:
char * buffer = new char[10];
__asm {
mov ecx,&buffer
mov edx,07
}
And the errors;
Error 1 error C2400: inline assembler syntax error in ‘second
operand’; found ‘AND’
What I’m doing wrong?
It all depends on what you are trying to achieve.
1. If you are trying to load the addres of the allocated
chararray intoecxThe value of
bufferalready is the address you need forecx. Its something like0x004F5A42(just for example) which is the address of thechararray in memory, so no reason for having&attached tobufferin your asm code.&bufferwould be the address of thebufferpointer itself which in memory may be megabytes away from thechararray.2. If you are trying to load the addres of
bufferintoecxYou should probably try this:
The reason for this workaround is that, as it appears, the role of
&is solely reserved to the AND operator. The following quote is taken from x86 Assembly Language Reference Manualand thereafter
&is never mentioned in the manual.