ADDRESSING MODES - Copy (1).pptx
Document Details
Uploaded by BrighterQuadrilateral
Full Transcript
ADDRESSING MODES By ELIAS KHOZA 01 Oct 2024 Why study Addressing modes Information involved in any operation performed by the CPU needs to be addressed. In computer terminology, such information is called the operand. Therefore, any instruction issued by the processor must...
ADDRESSING MODES By ELIAS KHOZA 01 Oct 2024 Why study Addressing modes Information involved in any operation performed by the CPU needs to be addressed. In computer terminology, such information is called the operand. Therefore, any instruction issued by the processor must carry at least two types of information. These are the operation to be performed, encoded in what is called the op-code field, and the address information of the operand on which the operation is to be performed, encoded in what is called the address field. The different ways in which operands can be addressed are called the addressing modes. Addressing modes differ in the way the address information of operands is specified. IMMEDIATE ADDRESSING (i) Immediate addressing. - The value of the operands is present in the instruction. - This mode can be used to define and use constants or set initial values of variables. - Its advantage is that no memory reference other than the instruction fetch is required to obtain the operand, thus saving one memory or cache cycle in the instruction cycle. - The disadvantage is that the size of the number is restricted to the size of the address field, which, in most instruction sets, is small compared with the word length. E.g. ADD 5 Means add the number 5 to something This uses immediate addressing for the value 5 The two’s complement representation for the number 5 is directly stored in the ADD instruction Must know value at assembly time IMMEDIATE ADDRESSING cont….. DIRECT ADDRESSING MODE - the address field contains the effective address of the operand. That is the address field contains the effective address of the operand: EA = A - It requires only one memory reference and no special calculation. The obvious limitation is that it provides only a limited address space. example, if the content of the memory location whose address is 1000 was (2345) at the time when the instruction LOAD 1000, Ri is executed, then the result of executing such instruction is to load the value (2345) into register Ri. Direct (absolute) addressing mode provides more flexibility compared to the immediate mode. DIRECT ADRESSING MODE cont….. INDIRECT ADDRESSING MODE - In this mode, the address field refers to the address of a word in memory which in turn contains the effective address of the operand. the length of the address field is usually less than the word length, thus limiting the address range. Hence, it has an address field refer to the address of a word in memory, which in turn contains a full-length address of the operand. E.g. Add Means “The data at memory location 100 is an address. Go to the address stored there and get that data and add it to the Accumulator” INDIRECT ADDRESSING cont… REGISTER ADDRESSING MODE - is similar to direct addressing. The only difference is that the address field refers to a register that contains the operand rather than a main memory address: EA = R - The advantages of register addressing are that (1) only a small address field is needed in the instruction, and (2) no time-consuming memory references are required. - The disadvantage of register addressing is that the address space is very limited. REGISTER ADDRESSING MODE cont…. DISPLACEMENT ADDRESSING MODE The instruction has two fields, at least one of which is explicit. The value contained in one address field (value = A) is used directly. The other address field refers to a register whose contents are added to produce the effective address (EA). - Displacement addressing requires that the instruction have two address fields, at least one of which is explicit. The value contained in one address field (value = A) is used directly. EA = A + (R) - The other address field, or an implicit reference based on opcode, refers to a register whose contents are added to A to produce the effective address. - three of the most common uses of displacement addressing are: Relative addressing Base-register addressing Indexing DISPLACEMENT ADDRESSING MODE cont.., Addressing modes examples Addressing modes examples Examples cont….. Examples cont……