RRX implementation in x86 assembly.

Post Reply
JRMoore
Junior Member
Posts: 7
Joined: Sun May 02, 2010 5:43 pm

RRX implementation in x86 assembly.

Post by JRMoore »

Hello, looking at the code I think I don't understand how RRX is implemented in x86 assembly.

 

The code right now is the following:

 

Code: Select all

#define RRX_OFFSET \
   __asm {                             \
       __asm bt dword ptr C_FLAG, 0    \
       __asm rcr offset, 1             \
   }

 

The bit test sets the carry flag, but I don't see it using the offset to get the LSB, instead it seems to be 0ing the carry flag, so the operation is a plain RCR.

 

Can somebody explain this to me? Thank you very much.


I'll be answering my own question, it's well implemented; I just needed to read some more documentation.

 

Both rotate through carry right (RCR) and rotate right with extend (RRX) allow a 33-bit rotation by using both the offset (in this case) and the carry flag.

 

In RCR the carry flag goes to the bit 31 and the bit 0 goes to the carry flag, which is essentially the same as the RRX does. The bit test op is needed to zero the carry flag in case it was set to 1 from a previous operation.

 

Kind regards.

Last edited by JRMoore on Tue May 04, 2010 9:22 pm, edited 1 time in total.
Post Reply