assemblyrotationeasy68k

easy68k partial rotation? (ROL/ROR)


So I know how ROL and ROR works for something like D0 = %00000100, if I ROR #1,D0 then D0 it will now be 00000010.

What I want to do is to rotate through only the a select few digits of that number, so for example if I ROR %00000001 one spot, I want it to be 00000100 instead of 10000000, so it only rotates through the last 3 bits of that number. Is there any way to do something like this where I set the bounds of the rotation so it doesn't go all the way back to the first bit?


Solution

  • There is "no silver bullet". You'd have to do it manually.

    1. Copy the register into another register.
    2. Clear the low 3-bits of the original register (AND with %11111000).
    3. Clear the other bits from the copy (AND with %00000111).
    4. Rotate the copy right.
    5. Copy the copy.
    6. Shift the second copy right 5 bits.
    7. OR the second copy with the first.
    8. Clear the upper bits from the first copy (AND with %00000111).
    9. OR the first copy with the original register.