21
Computer Organization & Assembly Language Instruction Execution Interrupts

Computer Organization & Assembly Language

  • Upload
    palila

  • View
    67

  • Download
    1

Embed Size (px)

DESCRIPTION

Computer Organization & Assembly Language. Instruction Execution Interrupts. Instruction Cycle. Fetch Fetch an instruction from memory Decode the instruction to determine the operation Fetch data from memory if necessary Execute Perform the operation on the data - PowerPoint PPT Presentation

Citation preview

Page 1: Computer Organization & Assembly Language

Computer Organization & Assembly Language

Instruction Execution Interrupts

Page 2: Computer Organization & Assembly Language

Instruction Cycle Fetch

1. Fetch an instruction from memory2. Decode the instruction to determine the operation3. Fetch data from memory if necessary

Execute4. Perform the operation on the data5. Store the result in memory if needed

2

Page 3: Computer Organization & Assembly Language

Fetch instruction: CPU reads an instruction from memory.

Interpret instruction: instruction is decoded to determine what action is required.

Fetch data: execution of an instruction may require reading data from memory or an I/O module.

Process data: Execution of an instruction may require performing some arithmetic or logical operation on data.

Write data: Result of an execution may require writing data to memory or an I/O module.

3

Page 4: Computer Organization & Assembly Language

Computer Components – Top Level View

4

Page 5: Computer Organization & Assembly Language

Contd.. CPU needs some internal memory Internal CPU Registers:

Program Counter (PC) = Address of instruction Instruction Register (IR) = Instruction being

executed Memory Address Register (MAR) = contains

address of a location in memory Memory Buffer Register (MBR) = contains a word

of data to be written to memory or the word most recently read.

Accumulator (AC) = Temporary Storage

5

Page 6: Computer Organization & Assembly Language

Contd.. Fetch the instruction from the memory Address in the Program Counter register

Program Counter (PC) holds address of next instruction to fetch

Increment the Program Counter Unless told otherwise

Instruction loaded into Instruction Register (IR) Decode the type of instruction Fetch the operands Execute the instruction Store the results

6

Page 7: Computer Organization & Assembly Language

Characteristics of a Hypothetical Machine

Instruction (16 bit) 4bits –opcode 12 bits –address

0001 = Load AC from memory 0010 = Store AC to memory 0101 = Add to AC from memory

7

Page 8: Computer Organization & Assembly Language

Example Program Execution

8

Page 9: Computer Organization & Assembly Language

Instruction Execution Cycle

I-1 I-2 I-3 I-4

PC Program (RAM)

I-1Instruction

Queue

op1op2Data

(RAM)

fetch

ALU

registers

store the output

decode

execute

9

Page 10: Computer Organization & Assembly Language

Instruction Cycle State Diagram

10

Page 11: Computer Organization & Assembly Language

Interrupts

Changing Program Flow

11

Page 12: Computer Organization & Assembly Language

Interrupts

Mechanism by which other modules (e.g. I/O) may interrupt normal sequence of processing

Program e.g. overflow, division by zero

Timer Generated by internal processor timer Used in pre-emptive multi-tasking

I/O from I/O controller

Hardware failure e.g. memory parity error

12

Page 13: Computer Organization & Assembly Language

Interrupt Cycle

Added to instruction cycle Processor checks for interrupt

Indicated by an interrupt signal If no interrupt, fetch next instruction If interrupt pending:

Suspend execution of current program Save context Set PC to start address of interrupt handler routine Process interrupt Restore context and continue interrupted program

13

Page 14: Computer Organization & Assembly Language

Transfer of Control via Interrupts

14

Page 15: Computer Organization & Assembly Language

Instruction Cycle with Interrupts

15

Page 16: Computer Organization & Assembly Language

Instruction Cycle (with Interrupts) - State Diagram

16

Page 17: Computer Organization & Assembly Language

Multiple Interrupts

Disable interrupts Processor will ignore further interrupts whilst

processing one interrupt Interrupts remain pending and are checked after

first interrupt has been processed Interrupts handled in sequence as they occur

Define priorities Low priority interrupts can be interrupted by higher

priority interrupts When higher priority interrupt has been processed,

processor returns to previous interrupt

17

Page 18: Computer Organization & Assembly Language

Multiple Interrupts - Sequential

18

Page 19: Computer Organization & Assembly Language

Multiple Interrupts – Nested

19

Page 20: Computer Organization & Assembly Language

Program Flow Control

20

Page 21: Computer Organization & Assembly Language

References

Chapter 1, Ytha Yu and Charles Marut, “Assembly Language Programming and Organization of IBM PC”

Chapter 3, William Stallings, “Computer Organization & Architecture”

21