I can’t compile this, how should I move [eax+4] to y in Visual Studio?
float x, y, z;
__asm
{
mov x, eax
mov y, [eax+4]
mov z, [eax+8]
}
EDIT:
Error 1 error C2424: ‘+’ : improper expression in ‘second operand’
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re using
eaxas a pointer, so storing that bit-pattern intofloat xseems unlikely. Perhaps you meant to copy 3 floats from memory at[eax+0], +4, and +8?@RaymondChen is right, you can use a temporary register to transfer it. The obvious choice is to pick ECX or EDX as a temporary; those along with EAX are call-clobbered so using them won’t force the compiler to save/restore them in the function containing your asm block.
Even though the values are
float, you can copy them with 32-bit integer registers instead of through XMM0 or an x87 register; you’re not doing FP math on them.If you knew
xandywere contiguous, you could copy 8 bytes at once with an XMM register.