In a recent assignment, I disassembled a binary written in C++.
In a few places throughout the program I came across shift operations by zero bits something like written below (The exact code/IDA isn't in front of me presently). The shift operations were all before a conditional branch.
...
call sub_123456
add esp, 8
shr eax, 0
cmp ...
jz ...
I have a decent understanding of assembly but I can't see why you'd do a bit shift of zero. Isn't this essentially a NOP? I've been looking for info on this but haven't come up with any definitive information. My guess is it's added by the compiler for some reason, though I'd like to understand why. The assignment is already submitted; this is just a question that's been nagging at me. Any input would be appreciated!
Thanks
eax=eax/1
shr
, arithmetic would besar
. And sometimes what we think compilers should do, makes even less sense. Because compilers these days are optimizing for a range of CPUs, for pipelining and so on. I'm with @VitalyOsipov regarding the potential cause, though.cmp
renders most of them changed. Also could be self-modified code