- Used for moving data within the computer.
- Register to Register.
- Register to Memory.
- Memory to Register.
- Constant to Register (only works for r16-r31).
- The ATmega32 cannot transfer directly from one Memory location to another Memory location.
- Does not affect flags
Register to Register
Copy Register
MOV Rd, Rr
- Moves (Copies) the value in register Rr to register Rd.
- Allows any register to be copied to any other register.
- Example: MOV r1, r10
- R1 receives the value stored in in R10.
Memory to Register
Load Direct from SRAM
LDS Rd, K
- Loads (Copies) the value in memory location K into register Rd.
- Rd may be any register.
- K may be any address between 0 and 65535.
- This is known as Direct addressing.
- Often use a variable to represent the memory address.
- Example: LDS R1, Data
- Data is a symbolic name of a memory location
- R1 receives the value stored in the memory location Data.
Load Indirect
LD Rd, X
- Loads (Copies) the value in memory location stored in the X register (R27:R26) into register Rd.
- This is known as Indirect addressing.
Load Indirect and Post-Increment
LD Rd, X+
- Loads (Copies) the value in memory location stored in the X register (R27:R26) into register Rd and increments the value in the X register.
- X is incremented after the copy.
- This is called post-increment.
Load Indirect and Pre-Decrement
LD Rd, -X
- Decrements the value in the X register and loads (Copies) the value in memory location stored in the X register (R27:R26) into register Rd.
- X is decremented before the copy.
- This is called pre-decrement.
Note: Similar instructions exist for Y (R29:R28) and Z (R31:R30) registers.
Constant to Register
Load Immediate
LDI Rd, K
- Rd may be R16-R31
- K may be 0-255
- Loads (Copies) the value of K into register Rd.
Register to Memory
Store Direct to SRAM
STS K, Rr
- Stores (Copies) the value in register Rr into memory location k.
- Rr may be any register.
- K may be any address between 0 and 65535.
- This is similar to LDS.
Store Indirect and Variants
ST X, Rr
- Stores (Copies) the value in register Rr into the memory location stored in the X register (R27:R26).
- This is known as Indirect addressing.
- Post-increment and pre-decrement instructions similar to LD are available:
- ST X+, Rr
- ST -X, Rr
- Note: Similar instructions exist for Y (R29:R28) and Z (R31:R30) registers.