mtctr

Move To Count Register

mtctr RS

Moves GPR to CTR. (Alias for 'mtspr 9, RS').

Details

Moves a value from a general-purpose register into the Count register (CTR), typically used to set up loop counts or branch targets for branch-to-CTR instructions. This is an alias for 'mtspr 9, RS' where SPR 9 designates CTR. No condition register flags are modified.

Pseudocode Operation

CTR ← RS

Programming Note

The mtctr instruction is commonly used to set up loop counters by moving values from a general-purpose register into the Count Register (CTR). Ensure that the source register contains the correct value for the desired loop iterations. This instruction operates at user privilege level and does not generate exceptions under normal conditions, but incorrect usage can lead to infinite loops if not managed properly.

Example

mtctr r3

Encoding

Binary Layout
31
0
RS
6
9
11
467
21
/
31
 
Format XFX-form
Opcode 0x7C0903A6
Extension Base
Registers Altered CTR

Operands

  • RS
    Source