CSSE 232 Computer Architecture I Exceptions 1 / 12 Class Status - - PowerPoint PPT Presentation

csse 232 computer architecture i
SMART_READER_LITE
LIVE PREVIEW

CSSE 232 Computer Architecture I Exceptions 1 / 12 Class Status - - PowerPoint PPT Presentation

CSSE 232 Computer Architecture I Exceptions 1 / 12 Class Status Reading for today B.7-8 2 / 12 Outline Definition Exception registers The process Special exception instructions Work on lab 3 / 12 Definition What is


slide-1
SLIDE 1

CSSE 232 Computer Architecture I

Exceptions

1 / 12

slide-2
SLIDE 2

Class Status

Reading for today

  • B.7-8

2 / 12

slide-3
SLIDE 3

Outline

  • Definition
  • Exception registers
  • The process
  • Special exception instructions
  • Work on lab

3 / 12

slide-4
SLIDE 4

Definition

What is an exception?

  • Unexpected events that interrupt normal program flow
  • Exception and interrupt not the same!
  • Exception - event from within the processor
  • Interrupt - event from outside the processor
  • Are they necessary?
  • What are the disadvantages of exceptions?

4 / 12

slide-5
SLIDE 5

What Exceptions have you seen?

Previous programming?

  • What did they look like?
  • When did they happen?
  • How did you solve them?

MIPS and SPIM

  • What did they look like?
  • When did they happen?
  • How did you solve them?

5 / 12

slide-6
SLIDE 6

Example

  • Exception generated during program execution
  • What should happen?

6 / 12

slide-7
SLIDE 7

Example

  • Exception generated during program execution
  • What should happen?
  • Should OS continue?

6 / 12

slide-8
SLIDE 8

Example

  • Exception generated during program execution
  • What should happen?
  • Should OS continue?
  • Should program continue running?
  • Possible ways to handle running program?

6 / 12

slide-9
SLIDE 9

Example

  • Exception generated during program execution
  • What should happen?
  • Should OS continue?
  • Should program continue running?
  • Possible ways to handle running program?
  • OS terminates the program
  • Skip offending instruction, continue
  • Retry offending instruction, continue

6 / 12

slide-10
SLIDE 10

Example

  • Exception generated during program execution
  • What should happen?
  • Should OS continue?
  • Should program continue running?
  • Possible ways to handle running program?
  • OS terminates the program
  • Skip offending instruction, continue
  • Retry offending instruction, continue
  • What does the processor need to continue running the

program?

6 / 12

slide-11
SLIDE 11

Important Exceptions registers

  • EPC
  • Stores address of bad instruction
  • Status Register
  • Stores the status of the exception
  • Exception being handled, ignore subsequent exceptions
  • Cause Register
  • Stores cause of exception

7 / 12

slide-12
SLIDE 12

Important Exceptions registers

Status register $12:

15 8 4 1 0 Interrupt mask User mode Exception level Interrupt enable

Cause register $13:

15 31 8 6 2 Pending interrupts Branch delay Exception code

8 / 12

slide-13
SLIDE 13

Process

  • In MIPS, exceptions managed by a System Control

Coprocessor (CP0) - a special location on the CPU

  • Only helps the main processor start exception handling.
  • Main processor runs the actual handler
  • Save PC of offending (or interrupted) instruction
  • In MIPS: Exception Program Counter (EPC)
  • Save indication of the problem
  • In MIPS: Cause register
  • Jump to handler at 8000 00180
  • Not the only way to do it. Book will talk about vectored

interrupts

9 / 12

slide-14
SLIDE 14

Special Instructions

  • mfc0
  • Move from coprocessor 0
  • mtc0
  • Move to coprocessor 0
  • eret
  • Return from exception (goes to EPC)

10 / 12

slide-15
SLIDE 15

Exception Handler

  • Read cause, transfer to relevant handler
  • In Handler
  • Determine action required
  • If restartable
  • Take corrective action
  • use EPC to return to program
  • Otherwise
  • Terminate program
  • Report error using EPC, cause, ?

11 / 12

slide-16
SLIDE 16

Work on Lab

  • Posted on course site

12 / 12