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
Posted on 2005-02-20 10:43:38 by jmachine
XOR eax, 0FFFFFFFFh
Posted on 2005-02-20 10:48:28 by donkey
Reverse as in bit mirroring? This forum contains the answer :-D

http://www.asmcommunity.net/board/viewtopic.php?t=6990
Posted on 2005-02-20 10:48:55 by roticv
Wow. Thanks for the fast reply. XOR with all ones is the same as not.

jmachine
Posted on 2005-02-20 10:55:03 by jmachine
jmachine,


That is a complement, not a reversal. Ratch
Posted on 2005-02-21 12:41:51 by 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).
Posted on 2005-02-21 14:55:58 by tenkey
Actually reversing eax,
mov ecx,32
rev:
shl eax,1
rcr ebx,1
loop rev
or eax,ebx

jmachine, you go to UofW right?
Posted on 2005-02-22 22:11:42 by 95se