0% found this document useful (0 votes)
164 views

Instructions Formats & Addressing Modes

I do not have enough information to fully answer this exercise question. The question does not provide the instruction format or specify an addressing mode, both of which are needed to determine the instruction fetch, effective address calculation, and register contents after instruction execution. More details about the computer architecture would be needed.

Uploaded by

Obsii Chala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
164 views

Instructions Formats & Addressing Modes

I do not have enough information to fully answer this exercise question. The question does not provide the instruction format or specify an addressing mode, both of which are needed to determine the instruction fetch, effective address calculation, and register contents after instruction execution. More details about the computer architecture would be needed.

Uploaded by

Obsii Chala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

• INSTRUCTIONS FORMATS &

ADDRESSING MODES
COMPUTER INSTRUCTION
• Program:- A sequence of machine instructions.
• Machine Instruction: - A group of bits that tell the
computer to perform a specific operation.

Instruction formats

• A computer instruction is often divided into two parts

—An opcode (Operation Code) that specifies the


operation for that instruction

—An address that specifies the registers and/or


locations in memory to use for that operation
STORED MEMORY CONCEPT

• The instructions of a program, along with any


needed data are stored in memory( van nueman
stored memory model)

Assume a memory has 4096 words in it. PROGRAM


Each word is 16 bits long
4096 = 212, so it takes 12 bits to select a DATA
word in memory
Addressing Modes
• 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, Direct, Indirect, Register, Register Indirect,


Displacement (Indexed) and Stack

• All computer architecture provide more than one address


modes.
— The point is
– How the control unit can determine which address mode is
being used in a particular instruction.
+ One or more bits of the instruction can be used as a mode fields.
– How to calculate the effective address.
Why different addressing modes?

• The address fields in typical instruction format


are relatively small.

• We would like to be able to reference a large


range of location in maim memory. To achieve
this objective, a variety of addressing technique
has been employed.

— There is a trade-off between address range(no. of


memory reference) and the complexity of
effective address calculation.
Immediate Addressing
• The simplest addressing mode, in which operand is part of
instruction.
• Example instruction: LOAD#1000,Ri. In this instruction, the
operation to be performed is to load a value into a register.
— Pro,
– No memory reference to fetch data, other than inst fetch. Fast

 It should be noted that in order to indicate that the value 1000


mentioned in the instruction is the operand itself and not its
address (immediate mode), it is customary to prefix the operand
by the special character (#).
Direct Addressing
• Simple but not common in current architecture.
• Address field contains address of operand
• Effective address (EA) = address field (A)
• e.g. ADD A
— Add contents of cell A to accumulator
— Look in memory at address A for operand
• Pro-
— Single memory reference to access data
— No additional calculations to work out effective address
• Cons-
• Limited address space/ Limited range, the size of mem refe
restrict to the size of addr. field
Direct Addressing Diagram
• Assume a system capable of 16 different types of operation and
has a 4kword. A word = 16bits
• 4bit for opcode and 12 bits for address reference. No problem
Instruction
Opcode Address A
Memory

Operand
Indirect Addressing (1)
• Memory cell pointed to by address field contains
the address of (pointer to) the operand
• EA = (A)
— Look in A, find address (A) and look there for operand
• e.g. ADD (A)
— Add contents of cell pointed to by contents of A to
accumulator
• Pro-
—Large address space
– 2n where n = word length
• Cons-
—Two memory refe to fetch the operand Hence
slower
Indirect Addressing Diagram
• Assume a system memory extended to 64k words. So how can
we address these 64k memory cells?
Instruction
Opcode Address A
Memory

Pointer to operand

Operand
Register Addressing (1)
• Operand is held in register named in address filed
• EA = R
• Similar to direct addressing except here the address field
refers to a register rather than a memory address.
• Limited number of registers
• The address field will have from 3 to 5 bits. Total of 8 or 32
registers can be referenced.
• pros.
— Very small address field needed
— Shorter instructions
— Faster instruction fetch
— No memory access
— Very fast execution
• Cons.
— Very limited Registers number and size
Register Addressing Diagram

Instruction
Opcode Register Address R
Registers

Operand
Register Indirect Addressing
• C.f. indirect addressing
• EA = (R)
• Operand is in memory cell pointed to by
contents of register R
• Large address space (2n)
• One fewer memory access than indirect
addressing
Register Indirect Addressing Diagram

Instruction
Opcode Register Address R
Memory

Registers

Pointer to Operand Operand


Displacement Addressing Diagram
Address field hold two values, EA = A + (R)
A = base value, R = register that holds displacement
Instruction

Opcode Register R Address A


Memory

Registers

Pointer to Operand + Operand


 Relative Addressing
— The referenced register R is the program counter (PC)-
the current instruction address.
– R = Program counter, PC
— The address field A holds displacement
— EA = A + (PC)
– get operand from A cells from current location pointed to by PC

 Indexed Addressing
— A = base, R = displacement
– EA = A + R
— Good for accessing arrays
– EA = A + R
– R++
Examples

• These are the values loaded into the accumulator for each
addressing mode.

17
Exercise
• The content of PC in the basic computer is 3AF (all
are in hexadecimal). The content of AC is 7EC3.
The content of memory at address 3AF is 932E. The
content of memory at address 32E is 09AC. The
content of memory at address 9AC is 8B9F.
 What is the instruction that will be fetched and
executed next?
 Show the binary operation that will be performed
in the AC when the instruction is executed.
 Give the contents of registers PC,AR, DR, AC,
and IR in hexadecimal

You might also like