Addressing modes in computer architecture
Addressing modes are techniques used in computer architecture to specify the location of an operand (data) required by an instruction. These modes determine how the instruction retrieves its operands. Here are the main types of addressing modes with examples:
1. Immediate Addressing Mode
- The operand is directly specified in the instruction.
- Example:
MOV A, #5 ; Move the value 5 directly into register A
2. Register Addressing Mode
- The operand is in a register, and the register's name is specified in the instruction.
- Example:
MOV A, B ; Move the contents of register B to register A
3. Direct Addressing Mode
- The effective address of the operand is given explicitly in the instruction.
- Example:
MOV A, 500 ; Move the value at memory address 500 to register A
4. Indirect Addressing Mode
- The effective address of the operand is held in a register or memory location.
- Example:
MOV A, @R0 ; Move the value at the address pointed to by R0 into register A
5. Indexed Addressing Mode
- The effective address is generated by adding a constant value to the contents of a register.
- Example:
MOV A, 2000(R1) ; Add 2000 to the contents of R1, and fetch the value from that address into A
6. Relative Addressing Mode
- The effective address is determined by the sum of the current program counter (PC) and an offset value.
- Example:
JMP LABEL ; Jump to the address calculated by PC + offset
7. Base Register Addressing Mode
- A base address stored in a base register is added to an offset to find the effective address.
- Example:
MOV A, 1000(BX) ; Fetch the value from [BX + 1000] into register A
Comments
Post a Comment