Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Architecture and the Fetch-Execute Cycle

Similar presentations


Presentation on theme: "Computer Architecture and the Fetch-Execute Cycle"— Presentation transcript:

1 Computer Architecture and the Fetch-Execute Cycle
Memory Addressing Techniques

2 Learning Objectives Explain the concepts of direct, indirect, indexed and relative addressing of memory when referring to low-level languages.

3 Memory Addressing Techniques
Direct Addressing Indirect Addressing Indexed Addressing Relative Addressing Immediate Addressing

4 1. Direct Addressing Means that the value in the address part of a machine code instruction is the address of the data. Simple to use but does not allow access to all memory addresses as there are memory addresses larger than can be held in the address part of an instruction. e.g. A 32-bit memory location may use 12 bits for the instruction code and 20 bits for the address of the data. This would allow for 2^12 (= 4096) instruction codes and 2^20 (= ) memory addresses. However, a computer using 32-bit memory locations will have 2^32 (= ) memory addresses. So direct addressing does not allow reference to all addresses e.g. for a computer using 32-bit memory locations, addresses from 2^20 – 2^32 cannot be referred to.

5 2. Indirect Addressing Means that the value in the address part of a machine code instruction is the address of the data.

6 Why use indirect addressing?
Allows more memory to be accessed than direct addressing as the full size of register is used for an address. If this value points to a location which holds nothing but an address then 2^32 locations in memory can be addressed.

7 3. Indexed Addressing Index Register (IR)
A special register used to adjust the address part of an instruction. The address given as part of the instruction is added to the contents of the index register (IR) to give the address of the data. Index register is then incremented.

8 Why use indexed addressing?
Allows a set of contiguous data locations (e.g. an array) to be accessed without altering the instruction. i.e. Address in instruction does not change, only contents of IR.

9 Indexed Addressing Instr. ADD 100 IR: Address Data: 100 ….. 101 102
Address Data: 100 ….. 101 102 103 104 105

10 Indexed Addressing Instr. ADD 100 IR: 1 Address Data: 100 ….. 101 102
103 104 105

11 Indexed Addressing Instr. ADD 100 IR: 2 Address Data: 100 ….. 101 102
103 104 105

12 Indexed Addressing Instr. ADD 100 IR: 3 Address Data: 100 ….. 101 102
103 104 105

13 Indexed Addressing Instr. ADD 100 IR: 4 Address Data: 100 ….. 101 102
103 104 105

14 Indexed Addressing Instr. ADD 100 IR: 5 Address Data: 100 ….. 101 102
103 104 105

15 Note The IR does not necessarily have to start at 0. Why?
To reach a particular field in a record with several fields. IR = Address of the start of the record. Instruction address = Offset of the required field from the start of the record. To reach an instruction in a program no matter where the program/page/segment is in main memory (see Memory Management Presentation or next 2 slides). IR = Address of the start of the program/page/segment (set by the loader). Instruction address = Offset of the required instruction from the start of the program/page/segment.

16 4. Relative Addressing Used only with jump instructions.
Address in the jump instruction is the displacement from the last address already in the PC from the previous instruction. The address in the instruction is added to the value in the PC. e.g. The current instruction is in address 3000 and is Jump *45*, using relative addressing this means that the line wants to jump to an instruction 45 lines ahead of the next instruction (due to the PC being automatically incremented by 1 during any Fetch-Decode-Execute-Reset Cycle this 46 lines ahead of the current instruction). The PC will have been incremented to 3001 (ready for the next instruction) so the PC is changed to = 3046. The next cycle retrieves the next instruction from there. The program knows where the line is relative to the current instruction but not the true address.

17 Index Table + Physical Address Displacement e.g. 3001+45 = 3046
Physical Page Number Logical Page Number Base Address 8 5 3000 Displacement e.g. 45 + Physical Address e.g = 3046

18 Segment Index Table Physical Address + e.g. 3501+131=3632 Displacement
For more research Physical Address e.g =3632 Displacement e.g. 131 + Segment Index Table Base Address Segment Size Segment 3500 1500 3

19 5. Immediate Addressing Immediate addressing is so-named because the value to be stored in memory immediately follows the operation code in memory. The instruction itself dictates what value will be stored in memory. For example, the instruction: MOV A,#20h I have used this in the form “Load 20” where 20 refers to a value and it is assumed that the 10 will go directly into the accumulator. This instruction uses Immediate Addressing because the Accumulator will be loaded with the value that immediately follows; in this case 20 (hexadecimal). Immediate addressing is very fast since the value to be loaded is included in the instruction. However, since the value to be loaded is fixed at compile-time it is not very flexible.

20 Immediate Addressing Advantage: Disadvantage:
No memory reference other than instruction fetch is required to obtain operand. Disadvantage: The size of the number is limited to the size of the address field, which most instruction sets is small compared to word length. This is the similar to the problem “direct addressing” has. For more research

21 Question State the 4 methods of memory addressing and explain why they are used.


Download ppt "Computer Architecture and the Fetch-Execute Cycle"

Similar presentations


Ads by Google