Professional Documents
Culture Documents
HARDWARE
PowerPoint Slides
by Manimaran
Learning Outcome(s)
Exception Processing
Multiple Exceptions
Special Exceptions
Exception Handlers
Halted:
Caused by system failure.
Exception:
Caused by system failure
Example:
- A divide-by-zero caused the processor to enter the exception state.
Privileged instructions:
Instructions for overwriting/ changing important memory locations.
May be executed only in the supervisor state.
Users are restricted from privileged instructions.
User Stack:
User Stack Pointer (USP)
Supervisor Stack:
Supervisor Stack Pointer (SSP)
Last Updated: I-Station Solutions Sdn Bhd 9
Figure 4.2: 68K SR (pg 106) [1]
Exception Setup:
Save current contents of the status register
Set S-bit high
Last Updated: 13/11/2017 I-Station Solutions Sdn Bhd 14
Example:
To clear the S-bit in the SR while leaving all other bits
unaffected:
AND SR
- For all exceptions (except Reset), current PC and SR are saved onto the system
stack.
- Exception code must end with an RTE to return the processor to the
task it was running before the exception occurred.
- The addresses for the exception handlers are restored with the high
word first, followed by the low word.
Last Updated: 13/11/2017 I-Station Solutions Sdn Bhd 23
Example:
A user writes code for a divide-by-zero exception handler
and places the routine at 7A238. The exception vector
table must be filled in the following way: Addresses 014
and 015 must contain 0007 (the high word of the starting
address), and locations 016 and 017 must contain A238
(the low word of the starting address). Even though the
68ks address bus is only 24 bits wide, the address must
occupy 32 bits in the vector table. This is accomplished by
making the upper 8 bits 0.