Addressing modes the addressing mode specifies a rule

  • Slides: 8
Download presentation
Addressing modes Ø the addressing mode specifies a rule for interpreting or modifying the

Addressing modes Ø the addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced Ø Benefits of addressing modes 1. to give programming versatility to the user 2. to reduce the number of bits in the addressing field of the instruction Ø Instruction format opcode mode address Opcode – specifies the operation to be performed Mode – addressing mode used to locate the operands needed for the operation Address – there may or may not be address field in the instruction

Implied mode > operand is specified implicitly in the definition of instruction. Ø Used

Implied mode > operand is specified implicitly in the definition of instruction. Ø Used for zero address and one address instructions. Ø Eg: INC A -> Increment Accumulator ADD -> add top most two elements of the stack CLA -> complement accumulator Immediate Mode Ø Operand is directly provided as constant Ø Operand can not be provided as variable, because value of variables can be changed after the executions of instruction. Variable should be stored in memory or registers before execution. Ø No computation required to calculate effective address. Ø Effective address – the address where the operand is stored Ø Eg : add R 1, #5 R 1<-R 1+5

Register Mode Ø Operand is present in register Ø Register number is written in

Register Mode Ø Operand is present in register Ø Register number is written in instruction Ø Eg: Load R 1 AC<-R 1 Ø Operand is stored in register R 1 Ø N bits are required to represent 2 raise to power n register Register Indirect Mode Ø Register contains the address of operand rather than operand itself Ø Eg: Load (R 1) AC<-M[(R 1)] Ø Address of operand is stored in register R 1 Ø Advantage: - Address field of the instruction uses fewer bits to select a register than would have been required to specify a memory address directly

Autoincrement or autodecrement mode Ø Special case of register indirect addressing mode Ø Use

Autoincrement or autodecrement mode Ø Special case of register indirect addressing mode Ø Use for sequentially access the data Ø Register is incremented or decremented after (or before) its value is used to access memory Ø Eg: load (R 1)+ AC<- M[(R 1)] Ø Finding the rest of addressing value by incrementing R 1, no need to load addresses again and again Direct addressing mode(Absolute addressing mode) Ø Actual address is given in instruction Ø Use to access variable Ø Because most of the variables are stored in memory Ø Eg: ADD X AC<- AC+M[X] Ø In above example, Effective address = X

Indirect Addressing Mode Ø used to implement pointers and passing parameters Ø Two times

Indirect Addressing Mode Ø used to implement pointers and passing parameters Ø Two times memory access required Ø Eg: ADD X AC<- AC+M[M[X]] Ø In above example , effective address=M[X] Relative Addressing Mode Ø Effective address = PC (program counter) + address part of instruction Ø Use for program control instruction like jump , branch Ø Eg: PC= 825 and address part of instruction contains number 24. Ø Instruction at location 825 is read from memory during fetch phase and then PC=PC+1=825+1=826 Ø So effective address = 826+24=850 Ø This is 24 memory locations forward from the address of the location Ø Make sure that firstly PC will be incremented and then added to given address

Base register addressing mode Ø Used in program relocation in memory when programs and

Base register addressing mode Ø Used in program relocation in memory when programs and data are moved form one segment of memory to another as required in multiprogramming system Ø After moving from one segment to another, program won’t get the same address as the previous one, this is called program relocation Ø Effective address= Base register content + address part of instruction Ø Base Register holds a base address of program Ø Eg: program P 1 is in mem address 100 to 109 and instruction is jump 158 then it will jump to 158 which is valid instruction Ø but if program p 1 is relocated and after this p 1 will be at mem address 400 to 499 then jump 158 is invalid Ø So instead of giving direct address we can give displacement and add to base register (jump 58 instead of jump 158) Ø Effective address = 400 +58 =458 which is valid

Indexed addressing mode Ø Use to access or implement array efficiently Ø Multiple registers

Indexed addressing mode Ø Use to access or implement array efficiently Ø Multiple registers required to implement Ø Give the base address in the instruction Ø So Any element can be accessed without changing instruction Ø Index register hold an index number that is relative Ø Effective address = base address + index register

RISC and CISC ØRISC – A computer with fewer instructions is known as reduced

RISC and CISC ØRISC – A computer with fewer instructions is known as reduced instruction set computer. ØCISC- A computer with large number of instructions is known as complex instruction set computer. ØExamples of CISC architecture- IBM 370 Computer and digital equipment corporation VAX computer ØCharacteristics of CISC architecture ØLarge no. of instruction(from 100 to 250 instructions) ØVariable length instruction format ØInstruction that manipulate operands in memory ØA large variety of addressing modes(5 to 20 diff modes) ØSome instruction that perform specialized tasks and are used infrequently