# `lsr`

[M68K Documentation](https://asm-editor.specy.app/documentation/m68k.md) › [Instructions](https://asm-editor.specy.app/documentation/m68k/instruction.md)

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/lsr

**Logical shift right**

Category: Shifts and rotates

Shifts the bits of the destination operand to the right.

Used in: [Arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/m68k/think-in-assembly/arithmetic-logic-and-bits.md) (M68K assembly), [The screen, keyboard and mouse through traps](https://asm-editor.specy.app/learn/courses/m68k/talking-to-the-outside-world/screen-keyboard-and-mouse.md) (M68K assembly), [Even or odd, count the set bits, multiply by shifting](https://asm-editor.specy.app/learn/courses/m68k/examples/bit-tricks.md) (M68K assembly), [Binary search](https://asm-editor.specy.app/learn/courses/m68k/examples/binary-search.md) (M68K assembly), [The snake game](https://asm-editor.specy.app/learn/courses/m68k/examples/snake.md) (M68K assembly), [Flappy ASM](https://asm-editor.specy.app/learn/courses/m68k/examples/flappy-asm.md) (M68K assembly), [Sampled sound](https://asm-editor.specy.app/learn/courses/m68k/examples/sampled-sound.md) (M68K assembly), [Arithmetic, logic and bits](https://asm-editor.specy.app/learn/courses/assembly-basics/think-in-assembly/arithmetic-logic-and-bits.md) (Assembly basics)

## Flags

| Flag | Effect |
| --- | --- |
| X | set from the result |
| N | set from the result |
| Z | set from the result |
| V | always 0 |
| C | set from the result |

## Forms

- `lsr <ea>, Dn` · Sizes .b .w .l, .w by default
  - Source: Dn, #imm
- `lsr <ea>` · Size .w
  - Operand: (An), (An)+, -(An), d(An), d(An,Xn), abs (memory alterable)

## Operands

- [`<ea>`](https://asm-editor.specy.app/documentation/m68k/addressing-mode.md): An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With `opt p=68020`, an allowed `d(An,Xn)` or `d(PC,Xn)` mode also permits the corresponding 68020 indexed and memory indirect forms. See [68020 addressing](https://asm-editor.specy.app/documentation/m68k/addressing-mode/68020.md).
- [`Dn`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): A data register, `d0` to `d7`.
- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): An immediate shift count from `1` to `8`, for example `#3`.

## Description

Two forms: (1) `ls<d> Dx/Im, Dn` shifts Dn by the count in Dx or immediate (1–8), any size. New bits are filled with 0s. Defaults to word. (2) `ls<d>.w (An)` shifts a memory word by 1; `.w` is the only size accepted and may be omitted.

## Example

```m68k
* --- LSR: logical shift right (fills with 0) ---
move.w #$FF00, d0
lsr.w #4, d0 ; d0 = $0FF0

* --- LSL: logical shift left (fills with 0) ---
move.w #$000F, d1
lsl.w #4, d1 ; d1 = $00F0

* --- Compare ASR vs LSR on negative value ---
move.w #$FF00, d2
asr.w #4, d2 ; d2 = $FFF0 (sign extended)
move.w #$FF00, d3
lsr.w #4, d3 ; d3 = $0FF0 (zero filled)

* --- Memory form: shifts word at (a0) right by 1 ---
lea $2000, a0 ; free memory: the program itself is at $1000
move.w #$0010, (a0)
lsr (a0) ; (a0) = $0008
```
