meljun cortes basic operational concepts

23
* Property of STI Page 1 of 23 Basic Operational Concepts 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.

Upload: meljun-cortes

Post on 22-Jan-2018

80 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: MELJUN CORTES Basic operational concepts

* Property of STIPage 1 of 23

Basic Operational Concepts

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.

Page 2: MELJUN CORTES Basic operational concepts

* Property of STIPage 2 of 23

Basic Operational Concepts

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.

Page 3: MELJUN CORTES Basic operational concepts

* Property of STIPage 3 of 23

Basic Operational Concepts

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.

Page 4: MELJUN CORTES Basic operational concepts

* Property of STIPage 4 of 23

Basic Operational Concepts

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 LOCAto the operand in a register in the processor, R0 and place the result into register R0.

Page 5: MELJUN CORTES Basic operational concepts

* Property of STIPage 5 of 23

Basic Operational Concepts

Computer Organization and Assembly Language

Connections Between the Processor and the MM

Main Memory

MAR

PC

IR

MDR

R0R1...

Rn-1

Control

ALU

n General PurposeRegisters

CPU

Page 6: MELJUN CORTES Basic operational concepts

* Property of STIPage 6 of 23

Basic Operational Concepts

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.

Page 7: MELJUN CORTES Basic operational concepts

* Property of STIPage 7 of 23

Basic Operational Concepts

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.

Page 8: MELJUN CORTES Basic operational concepts

* Property of STIPage 8 of 23

Basic Operational Concepts

Computer Organization and Assembly Language

CPU Instruction Execution Steps

Ø Instruction execution in a CPU can now be summarized by the following steps:

1. Fetching the instruction. 2. Incrementing the PC. 3. Decoding the instruction 4. Determining the location of data in the

memory, if necessary. 5. Fetching the required data into

internal CPU registers.6. Executing the instruction. 7. Storing the results. 8. Return to Step 1.

Page 9: MELJUN CORTES Basic operational concepts

* Property of STIPage 9 of 23

Basic Operational Concepts

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 Bus2. Address Bus3. Control Bus

Page 10: MELJUN CORTES Basic operational concepts

* Property of STIPage 10 of 23

Basic Operational Concepts

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.

Page 11: MELJUN CORTES Basic operational concepts

* Property of STIPage 11 of 23

Basic Operational Concepts

Computer Organization and Assembly Language

Two - Bus Structure

Input

OutputProcessor Memory

I/O Bus

MemoryBus

Input

OutputMemory Processor

I/O Bus

MemoryBus

Configuration 2

Configuration 1

Page 12: MELJUN CORTES Basic operational concepts

* Property of STIPage 12 of 23

Basic Operational Concepts

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.

bn-1 b0b1. . .

.

.

.

.

.

.

01

i

M - 1

Addressesn bits

word 0word 1

word i

word M - 1

Page 13: MELJUN CORTES Basic operational concepts

* Property of STIPage 13 of 23

Basic Operational Concepts

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

OperationField

Addressing Information

Page 14: MELJUN CORTES Basic operational concepts

* Property of STIPage 14 of 23

Basic Operational Concepts

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.

Page 15: MELJUN CORTES Basic operational concepts

* Property of STIPage 15 of 23

Basic Operational Concepts

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.

Page 16: MELJUN CORTES Basic operational concepts

* Property of STIPage 16 of 23

Basic Operational Concepts

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.

Page 17: MELJUN CORTES Basic operational concepts

* Property of STIPage 17 of 23

Basic Operational Concepts

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 operandsA = destination operands

Page 18: MELJUN CORTES Basic operational concepts

* Property of STIPage 18 of 23

Basic Operational Concepts

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 ACC [A] + [ACC]

v Add the contents of memory location Ato the contents of the accumulator and place the sum into the accumulator.

Page 19: MELJUN CORTES Basic operational concepts

* Property of STIPage 19 of 23

Basic Operational Concepts

Computer Organization and Assembly Language

Examples

Ø LOAD A ACC [A]

Ø ADD B ACC [B] + [ACC]

Ø STORE C C [ACC]

Page 20: MELJUN CORTES Basic operational concepts

* Property of STIPage 20 of 23

Basic Operational Concepts

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)

Page 21: MELJUN CORTES Basic operational concepts

* Property of STIPage 21 of 23

Basic Operational Concepts

Computer Organization and Assembly Language

Two-Phase Procedure in Instruction Execution

Ø Instruction Fetchv Instruction is fetched from MM location

whose address is in the program counter.

Ø Instruction Executev The instruction in the instruction

register is examined to determine which operation is to be performed.

Page 22: MELJUN CORTES Basic operational concepts

* Property of STIPage 22 of 23

Basic Operational Concepts

Computer Organization and Assembly Language

Instruction Execution and Straight-Line Sequencing

MOVE R0, AADD R0, B

.

.

.

.

.

.

ii + 1

Addresses Contents

MOVE C, R0i + 2

A...

B

C

3-InstructionProgramSegment

Data for theprogram

Page 23: MELJUN CORTES Basic operational concepts

* Property of STIPage 23 of 23

Basic Operational Concepts

Computer Organization and Assembly Language

Branching

CLEAR R0MOVE R1, N

Determine address of"Next" number and

add "Next" number toR0

DEC R1

Branch > 0LOOPSTART

.

.

.SUM

NUM1NUM2

.

.

.NUMn

LOOPSTART

MOVE SUM, R0

N

ProgramLoop