Addressing Modes in Assembly Language and Machine Code
Absolute Addressing
- The contents of the memory location specified in the operand are used.
Example:
- Memory location with address 200 contains the value 20.
- Instruction `LDD 200` stores 20 in the accumulator.
Direct Addressing
- Same as absolute addressing. The operand specifies the memory location
directly.
Example:
- Memory location with address 200 contains the value 20.
- Instruction `LDD 200` stores 20 in the accumulator.
Indirect Addressing
- The contents of the memory location specified in the operand are a pointer to
the actual value.
-Example:
- Memory location 200 holds the address 20.
- Memory location 20 contains the value 5.
- Instruction `LDI 200` stores 5 in the accumulator.
Indexed Addressing
- Adds the contents of the Index Register (IR) to the memory address in the
operand to get the actual memory location.
Example:
- IR contains value 4.
- Memory location 204 contains the value 17.
- Instruction `LDX 200` stores 17 in the accumulator.
Immediate Addressing
- The operand itself is the value to be used (instead of an address).
Example:
- Instruction `LDM #200` stores 200 in the accumulator.
Relative Addressing
- The memory address is the current memory address added to the operand
value.
Example:
- Instruction `JMR #5` transfers control to the instruction 5 locations after the
current one.
Symbolic Addressing
- Used in assembly language, where a label (symbol) is used instead of an
actual address.
Example:
- Memory location labelled `MyStore` contains the value 20.
- Instruction `LDD MyStore` stores 20 in the accumulator.
Labels in Assembly Language
- Labels assign a symbolic name to a memory location or an instruction.
Example: `<label>: <opcode> <operand>` for labeling an instruction.
Example: `<label>: n` for giving a symbolic address to the memory location
containing `n`.