Very simple question here…I’m trying to wrap my head around assembler and curious as to whether these to operations are equivalent:
mov [ebx], 5
and
lea esi, ebx
mov esi, 5
Thanks!
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.
No.
mov [ebx], 5puts the value 5 into the address pointed to by ebx (at least that’s the general idea of what it should do. MASM, for one, will reject it because it doesn’t know what size of destination you want, so you’d needmov byte ptr [ebx], 5, ormov word ptr [ebx], 5, etc.)The second copies ebx into esi, then copies 5 into esi. It doesn’t (even attempt to) move anything into memory. What you’re (apparently) looking for would be more like:
Again, you’ll run into the same thing though: you’ll need to specify
byte ptrorword ptr, or whatever. Also note that in this case, it’s rather wasteful to uselea— you’re doing the exact equivalent ofmov esi, ebx. You normally only useleawhen you want to do a more complex address calculation, something like:lea esi, ebx*4+ebp.