LSR (Logical Shift Right)

[operand] = [operand] >> 1

LSR shifts all the bits of an operand one place to the right.

The Carry flag is set to the value of the least significant bit that is shifted out of the operand. Before the shift, the Carry flag has no effect on the operation.

LSR can operate on both memory locations and the accumulator register (A). When used on memory, the operand is the value stored at the specified memory address.

Addressing Modes

LSR supports the following addressing modes:

Mode

Syntax

Bytes

Cycles

Implied

LSR A

4A

2

Zero Page

LSR zp

46 nn

5

Zero Page + X

LSR zp,X

56 nn

6

Absolute

LSR addr

4E ll hh

6

Absolute + X

LSR addr,X

5E ll hh

7

Flags Affected

  • N (Negative) – Set to 0, since the most significant bit is always 0.

  • Z (Zero) – Set if the result is zero; otherwise, it is cleared.

  • C (Carry) – Set to the value of the least significant bit before it is shifted out.

Examples

Shift Accumulator Right

    LDA #5    ; load A with binary 00000101
    LSR A     ; A now contains binary 00000010, C is set to 1

Shift Memory Right

    LDX #$10  ; load X with 16
    LSR $00,X ; Shift the value at address $0010 right

See Also

  • ASL (Arithmetic Shift Left)

  • ROL (ROtate Left)

  • ROR (ROtate Right)

Comments