LDR TEST
ORG #800
WORD #1010
DATA WORD #2020
WORD #3030
ORG #100
CODE
MOVL DATA R0
MOVH DATA R0
R0 now points to address 802 R0 = 802
LDR R0, #0, R1 → R1 = #2020
LDR R0, #2, R1 → R1 = #3030
LDR R0. $-2, R1 → R1 = #1010
END CODE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALU and PSW
Addressing modes:
Register
- talking about the effective address
- in register addressing, the EA is the register number
- Rvalue and Lvalue are obtained from the instruction
- CPU does not access memory.
Direct
- memory address is absolute
- EA is the address of the memory location
- e.g. ADDA @#1234
Immediate
- data is embedded in the instruction
- EA of embedded data:
→ Rvalue EA ← PC
→ Lvalue: impossible
Indirect
- address of address in insrtuction
- instruction contains an address (register or constant)
- address indicates the address of the data
- indirect EA
→ EA ← addr
→ EA ← memory[EA]
⇒ Rvalue CPU ← Memory[EA]
⇒ Lvalue: Memory[EA] ← CPU
Relative
- offset embedded in instruction
Indexed
- variation of direct
- increment or decrement register before or after memory access Index