1
1
הנבמ םיבשחמ
ta8
Spring 2006 Amar Lior
Adapted from Computer Organization&Design, H/S interface, Patterson Hennessy@UCB,3rd edition 2
Exceptions and Interrupts
Exception: An unscheduled event that
disrupts program execution and change its flow
Interrupts: An exception that comes from
- utside of the processor
3
Exception types:
Program
e.g. overflow, division by zero, using undefined
instruction
Invoking the operating system from user
program systemcall
Timer
Generated by internal processor timer Used in pre-emptive multi-tasking
I/O
from I/O controller (keyboard, disk)
Hardware failure
e.g. memory parity error 4
System call example
.include "defines.h" .data hello: .string "hello world\n" .text .globl _start _start: movl $SYS_write,%eax // SYS_write = 4 movl $STDOUT,%ebx // fd = fileno(stdio) movl $hello,%ecx // buf = str movl $12,%edx // count = 0x6 int $0x80 movl $SYS_exit,%eax xorl %ebx,%ebx int $0x80 ret
5
Program Flow Control
6
How Exception are Handled
The address of the affected address is saved
in the EPC register
The cause of the register is used to record
the exception type.
Than the process jump to the exception
address which is the operating system entry point for exception handling
In MIPS 0x8000 0180 In SPIM 0x8000 0080