Shift

OpcodeActionFlagsDescription
ASL Rx,#

Rx << Imm

Z, C

Rx will be left shifted from 1 to 16 times depending on the immediate value.

The "empty" bit(s) are filled with 0's.

The last bit shifted out will be put into the carry flag.

If the result of the shift is 0, the Z flag will be set.

LSR Rx,#

Rx >> Imm

Z, C

Rx will be right shifted from 1 to 16 times depending on the immediate value.

The &quote;empty&quote; bits are filled with 0's.

The last bit shifted out will be put into the carry flag.

If the result of the shift is 0, the Z flag will be set.

ROL Rx,#

{Rx, C} << Imm

Z, C

Rx will be left shifted from 1 to 16 times, with carry being input the first shift, then 0's after.

Carry will be the last bit shifted out of bit 31.

For a shift of 1 this means carry will be shifted into bit 0 of Rx, and bit 31 of Rx will be placed into carry, and the other bits in the register shift left by 1.

For a shift of two, the carry flag will be placed into bit 1 of Rx, and bit 30 of Rx will be placed into carry.

Bit 31 of Rx is lost, and bit 0 of Rx will have 0 shifted in with the other bits left shifted twice.

If the result of the shift is 0, the Z flag will be set.

ROR Rx,#

{C,Rx} >> Imm

Z, C

Rx will be right shifted from 1 to 16 times.

Works the same as ROL, except in the right shift direction.

ASL Rx,Ry

Rx << Ry

Z, C

Works the same as ASL Rx,# only the shift amount is specified by Ry.

Only the lower 5 bits of Ry are used to specify the shift.

A shift of 0 is now allowed, and will act like a shift of 1.

This limits the shift amount from 1 to 32.

LSR Rx,Ry

Rx >> Ry

Z, C

Works the same as LSR Rx,# only the shift amount is specified by Ry.

The same rules apply with regards to shift amount as LSR Rx,Ry above.

ROL Rx,Ry

{Rx,C} << Ry

Z, C

Works the same as ROL Rx,# only the shift amount is specified by Ry.

Previous rules apply.

ROR Rx,Ry

{C,Rx} >> Ry

Z, C

Works the same as ROR Rx,$ only the shift amount is specified by Ry.

Previous rules apply.