Exceptions are caused by program execution:
Integer arithmetic overflow – result outside [−231, +231)
Division by zero
Illegal instruction – machine code doesn’t make sense
Address error – access to unaligned address
Bus error – access to non-existent address
syscall instruction – when we need an OS request
brk (breakpoint) instruction – used by debuggers
Can be thought of as a synchronous software interrupt. . .
Interrupts arise from external devices:
Disk read complete (via DMA, say)
Memory error (but only with EEC RAM)
User pressed a key on console
Console ready to display another character
Hardware timer expired
Can be thought of as asynchronous hardware exception
Exception Handlers
Hardware saves current PC in a special register
CPU jumps to an exception handler, which
Saves the current processor state
Take appropriate internal action for an exception, or
Deal with the external source of the interrupt
Restores the previous processor state
Resumes user program execution, if possible
BadVAddr $8 offending memory reference
Count $9 current timer; incremented every 10ms
Compare $11 interrupt when Count = Compare
Status $12 controls which interrupts are enabled
Cause $13 exception type, and pending interrupts
EPC $14 PC where exception/interrupt occured
Interrupt mask which of the 8 interrupts are allowed
User mode not simulated by SPIM; always 1
Exception level automatically set during an exception; prevents handler itself being interrupted
Interrupt enable global interrupt enable (or disable)
Tuesday, 15 May 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment