Hello all. And no, this is not a homework assignment. I am going through the above book and in chapter 6 section review 6.2.9 here is the question.
6. Write a single instruction that reverses all the bits in EAX (do not use the not instruction).
I cannot figure this one out. Why would there be a not instruction if there was another way of doing this?
Does anyone know how to do this?
jmachine
6. Write a single instruction that reverses all the bits in EAX (do not use the not instruction).
I cannot figure this one out. Why would there be a not instruction if there was another way of doing this?
Does anyone know how to do this?
jmachine
XOR eax, 0FFFFFFFFh
Reverse as in bit mirroring? This forum contains the answer :-D
http://www.asmcommunity.net/board/viewtopic.php?t=6990
http://www.asmcommunity.net/board/viewtopic.php?t=6990
Wow. Thanks for the fast reply. XOR with all ones is the same as not.
jmachine
jmachine
jmachine,
That is a complement, not a reversal. Ratch
That is a complement, not a reversal. Ratch
Wow. Thanks for the fast reply. XOR with all ones is the same as not.
That's right. XOR can be described as "bit complement using a bit mask". Everywhere the bit mask has a 1 bit, the corresponding bit in the other operand will get complemented (what Irvine called a reversal).
Actually reversing eax,
mov ecx,32
rev:
shl eax,1
rcr ebx,1
loop rev
or eax,ebx
jmachine, you go to UofW right?
mov ecx,32
rev:
shl eax,1
rcr ebx,1
loop rev
or eax,ebx
jmachine, you go to UofW right?