14
CSC 222: Computer Organization & Assembly Language 6 - Interrupts Handling

Interrupts in assembly language x-8086

Embed Size (px)

Citation preview

Page 1: Interrupts in assembly language x-8086

CSC 222: Computer Organization

& Assembly Language

6 - Interrupts Handling

Page 2: Interrupts in assembly language x-8086

Basic Instruction Cycle

Fetch Decode Execute

Fetch

1. Fetch an instruction from memory

2. Decode the instruction to determine the operation

3. Fetch data from memory if necessary

Execute

4. Perform the operation on the data

5. Store the result in memory if needed

2

Page 3: Interrupts in assembly language x-8086

Instruction Cycle State Diagram

3

Page 4: Interrupts in assembly language x-8086

Contd..

4

Instruction Fetch Read instruction from memory into processor

Instruction Operation Decoding Determine the type of operation to be performed and operand(s) to

be used.

Operand Address Calculation If operation involves reference to an operand in memory or I/O, then

determine the address of operand.

Operand Fetch Fetch from memory or read from I/O

Data Operation Perform the operation

Operand Store Write into memory or out to I/O if required

Page 5: Interrupts in assembly language x-8086

Interrupts – Changing Program Flow

Mechanism by which other modules (e.g. I/O) may interrupt

normal sequence of processing

Hardware interrupts

Hardware devices to interrupt the processor for some I/O

operation.

Software interrupts

Sent by programs to request system services.

Sent by programs using the INT instruction.

Handling follows a similar procedure to hardware interrupts.

5

Page 6: Interrupts in assembly language x-8086

Interrupts…

6

Processor exception

System generated interrupts

Occurs when some condition arises in the processor which

requires special handling.

Each exception has a unique handling number

Page 7: Interrupts in assembly language x-8086

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

7

Page 8: Interrupts in assembly language x-8086

Transfer of Control via Interrupts

8

Page 9: Interrupts in assembly language x-8086

Instruction Cycle with Interrupts

9

Page 10: Interrupts in assembly language x-8086

Instruction Cycle (with Interrupts) - State Diagram

10

Page 11: Interrupts in assembly language x-8086

Multiple Interrupts

Disable interrupts

Processor will ignore further interrupts while 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

11

Page 12: Interrupts in assembly language x-8086

Multiple Interrupts - Sequential

12

Page 13: Interrupts in assembly language x-8086

Multiple Interrupts – Nested

13

Page 14: Interrupts in assembly language x-8086

Chapter Reading

14

Chapter 3, William Stallings, “Computer Organization

& Architecture”