mtsr
Move to Segment Register - 7C 00 01 64
mtsr

Instruction Syntax

Mnemonic Format Description
mtsr SR,rS Move to Segment Register

Instruction Encoding

0
1
1
1
1
1
S
S
S
S
S
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

Field Bits Description
Primary Opcode 0-5 011111 (0x1F)
rS 6-10 Source register
Reserved 11-15 00000
Reserved 16-20 00000
Reserved 21-29 000000000
Reserved 30 0
SPR 31-31 Special Purpose Register (Segment Register)

Operation

SR ← (rS)

The contents of register rS are copied into the specified Segment Register (SR).

Affected Registers

Segment Register (SR)

(always)

Examples

Basic Move to Segment Register

mtsr 0, r3     # Copy value from r3 to SR0

Memory Management Setup

# Set up segment register for memory management
lis r3, 0x8000  # Load segment value
ori r3, r3, 0x0001  # Set segment attributes
mtsr 1, r3      # Set SR1 for segment 1

Multiple Segment Configuration

# Configure multiple segment registers
li r3, 0x0001   # Segment 0 configuration
mtsr 0, r3      # Set SR0
li r4, 0x0002   # Segment 1 configuration  
mtsr 1, r4      # Set SR1
li r5, 0x0003   # Segment 2 configuration
mtsr 2, r5      # Set SR2

Dynamic Segment Allocation

# Dynamically allocate segment
lis r3, segment_base@ha
addi r3, r3, segment_base@l
ori r3, r3, 0x0001  # Add segment attributes
mtsr 5, r3      # Allocate segment 5

Segment Register Save/Restore

# Save and restore segment register
mfsr r10, 3     # Save SR3
# ... modify SR3 ...
mtsr 3, r10     # Restore SR3

Related Instructions

mfsr, mtsrin, mtspr, mfspr

Back to Index