• No results found

Instruction Format and Addressing Modes

N/A
N/A
Protected

Academic year: 2021

Share "Instruction Format and Addressing Modes"

Copied!
30
0
0

Loading.... (view fulltext now)

Full text

(1)

Instruction format

Instruction format

And

And

Addressing modes

Addressing modes

Prepared by Madhurima Patra Prepared by Madhurima Patra 14401062011

(2)
(3)

Instruction format

Instruction format

An instruction format defines the layout of the bits of An instruction format defines the layout of the bits of 

an instruction, in terms of its constituent parts . an instruction, in terms of its constituent parts . •

The bits of the instruction are divided into groupsThe bits of the instruction are divided into groups

called fields. The most common fields are called fields. The most common fields are

• An operation code that specifies the operation to beAn operation code that specifies the operation to be performed.

performed.

An address field that specifies a An address field that specifies a memory address ormemory address or

register. register.

• A mode field that tells us how the operand or theA mode field that tells us how the operand or the effective address of the operand is to be found out. effective address of the operand is to be found out.

(4)

Types of instruction formats

Types of instruction formats

Various types of instruction formats Various types of instruction formats •

Three address instructionsThree address instructions

Two address instructionsTwo address instructions

One address instructionsOne address instructions

(5)

Three address instructions

• Computers with three address instructions use three address fields to specify either a

 processor register or a memory operand. • For example

ADD R1, A, B R1M[A] + M[B]

As shown, it is clear that in the instruction 3 addresses are specified. In the above instruction one register 

address and two memory addresses are specified. Example of computer using this type of instructions Cyber 170.

(6)

Two address instructions

• Computers that use this type of instruction have two addresses specified in their instructions.

• For example

ADD R1, A R1 R1 + M[A]

In this instruction one register is specified and one memory operand is specified.

In this instruction register R1 is both the source and the destination.

Most commercial computers use this type of  instructions.

(7)

One address instructions

• In this type of instructions an implied accumulator  register is used for all data manipulation.

• For example

LOAD A ACM[A]

ADD B ACAC + M[B]

All operations are done between the AC register and a memory operand.

Commercially available computers also use this type of instruction format.

(8)

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 .

• For example

PUSH A TOSA PUSH B TOSB

ADD TOS(A+B)

The ADD instruction does not need any address field. Example Burroughs large systems

(9)

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.

• The way the operands are chosen is dependent on the addressing mode.

(10)

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

(11)

Implied addressing mode

• In this mode the operands are specified implicitly in the definition of the instruction.

• 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.

(12)

Implied addressing mode diagram

Opcode

CMA Instruction

(13)

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

(14)

Immediate addressing mode diagram

Operand Opcode

Instruction

(15)

Direct addressing mode

• Address field contains address of operand • Effective address (EA) = address field (A) • e.g. LDA A

• Look in memory at address A for operand which is to be loaded in the accumulator.

• 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

(16)

Direct addressing mode diagram

Address A Opcode Instruction Memory Operand A

(17)

Indirect addressing mode

• Memory cell pointed to by address field contains the address of (pointer to) the operand.

• EA = address contained in memory location M

• Look in M, 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

(18)

Indirect addressing mode diagram

Address M Opcode Instruction Memory Operand Pointer to operand

(19)

Register addressing mode

• Operand is held in register named in the address field. • EA = R 

• Example ADD B

Advantages and disadvantages

•  No memory access. So very fast execution. • Very small address field needed .

• Shorter instructions

• Faster instruction fetch

• Limited number of registers.

• Multiple registers helps performance

• Requires good assembly programming or compiler writing

(20)

Register addressing mode diagram

Register Address R  Opcode Instruction Registers Operand

(21)

Register Indirect addressing mode

• In this the instruction specifies a register whose

contents give the address of the operand in memory. • 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.

(22)

Register Indirect addressing mode diagram Register Address R  Opcode Instruction Memory Operand Pointer to Operand Registers

(23)

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. • For example

INR R1

will increment the register R1. DCR R2

(24)

Autoincrement or Autodecrement addressing mode diagram Register Address R  Opcode Instruction Memory Operand value Registers value++ Operand

(25)

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.

• EA = A + contents of PC

• Example : PC contains 825 and address part of instruction contains 24.

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.e. 24 memory locations forward

(26)

Relative addressing mode diagram

Opcode Instruction Memory Operand Contents of register  Program counter  Address A +

(27)

Indexed addressing mode

• The contents of an index register is added to the address field of the instruction to get the effective address.

• The address field of the instruction is the beginning address of the data array in the memory.

• Index register contains a index value which can be incremented or decremented as required.

• Therefore

EA = A + IR 

• Example MOV AL , DS: disp [SI] Advantage

(28)

Indexed addressing mode diagram

I R  Opcode Instruction Memory Operand Contents of register  Index Register  Address A + A

(29)

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.

• Therefore

EA= A + BR  • For example:

MOV AL, disp [BX]

(30)

Base Register addressing mode diagram

BR  Opcode Instruction Memory Operand Contents of register  Base Register  Address A + Value of BR 

References

Related documents

Pada penelitian ini akan dilakukan pengujian aktivitas antimalaria ekstrak etanol dan senyawa andrografolida dari herba sambiloto secara in vitro terhadap tahapan perkembangan

Real estate limited partnerships (RELPs) trade in the secondary market at discounted prices compared to their NAVs. Business appraisers consider these discounts a proxy for

Activation energy, The dielectric loss and The dielectric constant of (PMMA-SPO-PS-TiC) nanocomposites decrease with increasing of Titanium carbide (TiC)

• In this mode, the effective address of the memory may be taken directly from index register specified by instruction.. Implied

• Displacement mode – the effective address of the operand is the sum of the contents of a register and a signed 16-bit displacement value given in the instruction.. • Register

Where the operand is at the memory location whose address is the sum of a register and a constant in the instruction

indexed, post increment addressing mode — In this addressing mode, the effective address of the operand is determined by the current value of the index register, added to a 0- or

The computer has an instruction format with 4 fields: an opcode field; a mode field to specify 1 of 7 addressing modes; a register address field to specify one of 60 registers; and