This action might not be possible to undo. Are you sure you want to continue?
Prepared by Madhurima Patra 14401062011
• An instruction format defines the layout of the bits of an instruction, in terms of its constituent parts . • The bits of the instruction are divided into groups called fields. The most common fields are
• An operation code that specifies the operation to be performed. • An address field that specifies a memory address or register. • A mode field that tells us how the operand or the effective address of the operand is to be found out.
Types of instruction formats
Various types of instruction formats • • • • Three address instructions Two address instructions One address instructions Zero address instructions
In the above instruction one register address and two memory addresses are specified. • For example ADD R1. Example of computer using this type of instructions Cyber 170. B R1M[A] + M[B] As shown. .Three address instructions • Computers with three address instructions use three address fields to specify either a processor register or a memory operand. A. it is clear that in the instruction 3 addresses are specified.
In this instruction register R1 is both the source and the destination. A R1 R1 + M[A] In this instruction one register is specified and one memory operand is specified. • For example ADD R1. Most commercial computers use this type of instructions.Two address instructions • Computers that use this type of instruction have two addresses specified in their instructions. .
• For example LOAD A ACM[A] ADD B ACAC + M[B] All operations are done between the AC register and a memory operand.One address instructions • In this type of instructions an implied accumulator register is used for all data manipulation. . Commercially available computers also use this type of instruction format.
• For example PUSH A TOSA PUSH B TOSB ADD TOS(A+B) The ADD instruction does not need any address field.Zero address instructions • A stack organized computer does not require an address field for computational instructions. • Due to the absence of the address field it is known as zero address instructions . Example Burroughs large systems .
• The way the operands are chosen is dependent on the addressing mode. .Addressing modes • What is addressing mode? • The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced.
Addressing Modes • • • • • • • • • • Implied addressing mode Immediate addressing mode Direct addressing mode Indirect addressing mode Register addressing mode Register Indirect addressing mode Autoincrement or Autodecrement addressing mode Relative addressing mode Indexed addressing mode Base register addressing mode .
• Example – ‘complement accumulator’ instruction CMA • Reason – from the definition itself it is obvious that we have to complement the operand that is placed in the accumulator. . • All register reference instructions that use an accumulator are implied mode instructions.Implied addressing mode • In this mode the operands are specified implicitly in the definition of the instruction.
Implied addressing mode diagram Instruction Opcode CMA .
Immediate addressing mode • Operand is part of instruction • Operand = address field • Example ADD 5 • Add 5 to contents of accumulator • 5 is operand Advantages and disadvantages • No memory reference to fetch data • Fast • Limited range .
Immediate addressing mode diagram Instruction Opcode Operand ADD 5 .
• Load contents of cell A to accumulator Advantages and disadvantages • Single memory reference to access data • No additional calculations to work out effective address • Limited address space . LDA A • Look in memory at address A for operand which is to be loaded in the accumulator.g.Direct addressing mode • Address field contains address of operand • Effective address (EA) = address field (A) • e.
Direct addressing mode diagram Instruction Opcode Address A Memory A Operand .
find address contained in M and look there for operand • For example ADD @M • Add contents of memory location pointed to by contents of M to accumulator . • EA = address contained in memory location M • Look in M.Indirect addressing mode • Memory cell pointed to by address field contains the address of (pointer to) the operand.
Indirect addressing mode diagram Instruction Opcode Address M Memory Pointer to operand Operand .
• Very small address field needed . • Shorter instructions • Faster instruction fetch • Limited number of registers.Register addressing mode • Operand is held in register named in the address field. • EA = R • Example ADD B Advantages and disadvantages • No memory access. • Multiple registers helps performance • Requires good assembly programming or compiler writing . So very fast execution.
Register addressing mode diagram Instruction Opcode Register Address R Registers Operand .
. • One fewer memory access than indirect addressing. • Therefore EA = the address stored in the register R • Operand is in memory cell pointed to by contents of register R • Example LDAX B Advantage • Less number of bits are required to specify the register.Register Indirect addressing mode • In this the instruction specifies a register whose contents give the address of the operand in memory.
Register Indirect addressing mode diagram Instruction Opcode Register Address R Memory Registers Pointer to Operand Operand .
DCR R2 will decrement the register R2. • For example INR R1 will increment the register R1. .Autoincrement or Autodecrement addressing mode • This mode is similar to register indirect mode except that the register is automatically incremented or decremented after its value is used to access memory. • This mode is specially useful when we want to access a table of data.
Autoincrement or Autodecrement addressing mode diagram Instruction Opcode Register Address R Memory Registers value value++ Operand Operand .
24 memory locations forward from the address of the next instruction.e. • EA = A + contents of PC • Example : PC contains 825 and address part of instruction contains 24.Relative addressing mode • In this mode the contents of the program counter is added to the address field of the instruction in order to obtain the effective address. . After the instruction is read from location 825. the PC is incremented to 826. So EA=826+24=850. The operand will be found at location 850 i.
Relative addressing mode diagram Instruction Opcode Address A Memory Program counter Contents of register + Operand .
• The address field of the instruction is the beginning address of the data array in the memory. .Indexed addressing mode • The contents of an index register is added to the address field of the instruction to get the effective address. • Therefore EA = A + IR • Example MOV AL . DS: disp [SI] Advantage • Good for accessing arrays. • Index register contains a index value which can be incremented or decremented as required.
Indexed addressing mode diagram Instruction Opcode IR Address A Memory Index Register Contents of register + Operand A .
• Therefore EA= A + BR • For example: MOV AL.Base Register addressing mode • In this mode the content of a base register is added to the address part of the instruction to obtain the effective address. • The base register contains the address of the beginning of the data array. disp [BX] Segment registers in 8086 .
Base Register addressing mode diagram Instruction Opcode BR Address A Memory Base Register Contents of register + Operand Value of BR .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.