You are on page 1of 23

Computer Organization and Assembly Language

How to Fetch/Read Data or
Instruction from MM

Ø

In order to fetch/read an instruction or
data from main memory:
1. The CPU first sends the address of
the memory location to be read.
2. The CPU then issues or sends the
read signal to the memory.
3. The word is then read out of memory
and is loaded into a CPU internal
register.

Basic Operational Concepts

* Property of STI
Page 1 of 23

Computer Organization and Assembly Language

How to Write/Store Data
into MM

Ø

In order to store/write data into main
memory:
1. The CPU first sends the address of
the memory location to be written.
2. The CPU then sends the write signal
together with the data or word to be
written to memory.

Basic Operational Concepts

* Property of STI
Page 2 of 23

Computer Organization and Assembly Language

Example 1

Ø

Example of a typical assembly language
instruction:
MOV R0, LOCA
v

Copy the contents at memory location
LOCA into a register in the processor,
R0.

Basic Operational Concepts

* Property of STI
Page 3 of 23

Computer Organization and Assembly Language

Example 2

Ø

Take a look at another example of a typical
assembly language instruction:
ADD R0, LOCA

Ø

Add the operand at memory location LOCA
to the operand in a register in the
processor, R0 and place the result into
register R0.

Basic Operational Concepts

* Property of STI
Page 4 of 23

Computer Organization and Assembly Language

Connections Between the
Processor and the MM

Main Memory

MAR
PC
IR

CPU

MDR
R0
R1
.
.
.
Rn-1

Control

ALU

n General Purpose
Registers

Basic Operational Concepts

* Property of STI
Page 5 of 23

Computer Organization and Assembly Language

Operating Steps
1. PC is set to point to the first instruction of
the program.
2. The contents of the PC are transferred to
the MAR and a Read signal is sent to the
MM.
3. The addressed word is read out of MM
and loaded into the MDR.
4. The contents of MDR are transferred to
the IR. The instruction is ready to be
decoded and executed.
5. During execution, the contents of the PC
are incremented or updated to point to the
next instruction.

Basic Operational Concepts

* Property of STI
Page 6 of 23

Computer Organization and Assembly Language

Exercise

Ø

Enumerate the different steps needed to
execute the machine instruction
ADD LOCA, R0

Ø

Assume that the instruction itself is stored
in the main memory at location INSTR,
and that this address is initially in register
PC.

Basic Operational Concepts

* Property of STI
Page 7 of 23

Computer Organization and Assembly Language

CPU Instruction Execution
Steps
Ø

Instruction execution in a CPU can now
be summarized by the following steps:
1.
2.
3.
4.
5.
6.
7.
8.

Fetching the instruction.
Incrementing the PC.
Decoding the instruction
Determining the location of data in the
memory, if necessary.
Fetching the required data into
internal CPU registers.
Executing the instruction.
Storing the results.
Return to Step 1.

Basic Operational Concepts

* Property of STI
Page 8 of 23

Computer Organization and Assembly Language

Bus Structure

Ø

A bus is a collection of wires that connect
several devices within a computer system.

Ø

Three main groupings of lines:
1. Data Bus
2. Address Bus
3. Control Bus

Basic Operational Concepts

* Property of STI
Page 9 of 23

Computer Organization and Assembly Language

Single Bus Structure

Input

Output

Memory

Processor

All units are connected to a single bus, so it
provides the sole means of interconnection.

Basic Operational Concepts

* Property of STI
Page 10 of 23

Computer Organization and Assembly Language

Two - Bus Structure

Configuration 1

Input
Processor
Output

Memory
Memory
Bus

I/O Bus

Configuration 2

Input
Memory
Output

Processor
Memory
Bus

I/O Bus

Basic Operational Concepts

* Property of STI
Page 11 of 23

Computer Organization and Assembly Language

Memory Locations and
Addresses
Ø

MM is organized so that a group of n bits
can be stored or retrieved in a single basic
operation.

n bits

Addresses
0

word 0

1

word 1
.
.
.

i

bn-1

. . .

b1 b0

word i

.
.
.
M-1

Basic Operational Concepts

word M - 1

* Property of STI
Page 12 of 23

Computer Organization and Assembly Language

Parts of an Instruction

Ø

An instruction usually contains two parts:
1. the part that specifies the operation to
be performed (op-code field).
2. the part that may be used to specify
operand addresses.

8 bits

24 bits

Operation
Field

Addressing Information

Basic Operational Concepts

* Property of STI
Page 13 of 23

Computer Organization and Assembly Language

Main Memory Operations

Ø

Fetch or Read. This transfers the contents
of a specific MM location to the CPU. The
word in the MM remains unchanged.

Ø

Store or Write. This transfers a word of
information from the CPU to a specific MM
location. This destroys the former contents
of that location.

Basic Operational Concepts

* Property of STI
Page 14 of 23

Computer Organization and Assembly Language

Instructions and
Instructions Sequencing

Ø

Types of Instructions:
1. Data transfers between MM and CPU
registers.
2. Arithmetic and logic operations on
data.
3. Program sequencing and control.
4. I/O operations or transfers.

Basic Operational Concepts

* Property of STI
Page 15 of 23

Computer Organization and Assembly Language

Notations
R1 [LOC]
Ø

The contents of memory location LOC are
transferred into register R1.
C

Ø

[A] + [B]

The operands in memory locations A and
B are fetched from MM and transferred
into the CPU, where they will be added in
the ALU. Then the resulting sum is to be
stored into memory location C in MM.

Basic Operational Concepts

* Property of STI
Page 16 of 23

Computer Organization and Assembly Language

Address Notations

Ø

Two-Address Instructions

ADD A, B
Ø

A

[A] + [B]

Three-Address Instructions

ADD A, B, C

A

[B] + [C]

B and C = source operands
A
= destination operands

Basic Operational Concepts

* Property of STI
Page 17 of 23

Computer Organization and Assembly Language

One-Address Notation

Ø

Ø

A general purpose CPU register,
usually called the accumulator,
may be used for this purpose.
Examples:

ADD A
v

ACC

[A] + [ACC]

Add the contents of memory location A
to the contents of the accumulator and
place the sum into the accumulator.

Basic Operational Concepts

* Property of STI
Page 18 of 23

Computer Organization and Assembly Language

Examples

Ø

LOAD A

ACC

[A]

Ø

ADD B

ACC

[B] + [ACC]

Ø

STORE C

Basic Operational Concepts

C

[ACC]

* Property of STI
Page 19 of 23

Computer Organization and Assembly Language

Zero-Address Instructions

Ø

Instructions where the locations of all
operands are defined implicitly.

Ø

Example:
v Inc (increment the accumulator by 1)
v

Dec (decrement the accumulator by 1)

Basic Operational Concepts

* Property of STI
Page 20 of 23

Computer Organization and Assembly Language

Two-Phase Procedure in
Instruction Execution

Ø

Instruction Fetch
v Instruction is fetched from MM location
whose address is in the program
counter.

Ø

Instruction Execute
v The instruction in the instruction
register is examined to determine which
operation is to be performed.

Basic Operational Concepts

* Property of STI
Page 21 of 23

Computer Organization and Assembly Language

Instruction Execution and
Straight-Line Sequencing

Addresses
i
i+1
i+2

Contents
MOVE R0, A
ADD R0, B
MOVE C, R0
.
.
.

3-Instruction
Program
Segment

A
.
.
.
B

Data for the
program

.
.
.
C

Basic Operational Concepts

* Property of STI
Page 22 of 23

Computer Organization and Assembly Language

Branching

CLEAR R0
MOVE R1, N
LOOPSTART Determine address of
"Next" number and
add "Next" number to
R0
DEC R1

Program
Loop

Branch > 0
LOOPSTART
MOVE SUM, R0
.
.
.
SUM
N
NUM1
NUM2
.
.
.
NUMn

Basic Operational Concepts

* Property of STI
Page 23 of 23