Operations:

Syntax:

Operation:

Operands:

Program Counter:

Opcode

Comment

Stack

ROR Rd

Rd:C = ROR(C:Rd)

0 <= d <= 31

PC = PC + 1

1001010ddddd0111

Description

Shifts all bits in Rd one place to the right. The C flag is shifted into bit 7 of Rd. Bit 0 is shifted into the C flag. This operation, combined with ASR, effectively divides multi-byte signed values by two. Combined with LSR, it effectively divides multi-byte unsigned values by two. The Carry flag can be used to round the result.

Status Register (SREG) and Boolean Formula

I

T

H

S

N XOR V, for signed tests.

V

N XOR C, for N and C after the shift.

N

R7

Set if MSB of the result is set; cleared otherwise.

Z

~R7 AND ~R6 AND ~R5 AND ~R4 AND ~R3 AND ~R2 AND ~R1 AND ~R0

Set if the result is 0x00; cleared otherwise.

C

Rd0

Set if, before the shift, the LSB of Rd was set; cleared otherwise.

R (Result)

R (Result) equals Rd after the operation.

Example:

      lsr   r19       ; Divide r19:r18 by two
      ror   r18       ; r19:r18 is an unsigned two-byte integer
      brcc  zeroenc1  ; Branch if carry cleared
      asr   r17       ; Divide r17:r16 by two
      ror   r16       ; r17:r16 is a signed two-byte integer
      brcc  zeroenc2  ; Branch if carry cleared
      ...
zeroenc1: 
      nop             ; Branch destination (do nothing)
      ...
zeroenc1: 
      nop             ; Branch destination (do nothing)

Words

1 (2 bytes)

Table Cycles

Name

Cycles

AVRe

1

AVRxm

1

AVRxt

1

AVRrc

1