RRX implementation in x86 assembly.
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.