Data aborts and prefetch aborts are the most common problems that can block people developing embedded code. The error is easy to make but hard to debug.
One of the reason it’s hard to debug is because after the exception occurs it can be hard to figure out the line of code that caused the exception.
In this assignment we will write our own little micro debugger.
Not only will the exercise be instructive, but it will also save time later on. It will make it easier to find source of exceptions and will provide a small test bed that can be expanded to be even more useful as the course goes on.
Data or Prefetch exception occurs. Each jumps through its vector to a respective handler. The handler save the context and sets R0 with a flag indicating the type of exception.
The handler then reads original link register value, adjusts it correctly and writes to r1. Then it calls a print routine the prints out the type of exception and the memory location it occured at.
The function should have this signature:
void abortPrint(UINT type, UINT address)
Write a test that lets you test both exceptions one after the other.
To do this you will need to either return from the exception handler or continue at a different location calling a different function.
To show it works, loop through both exceptions 10 times, printing a count each time and exit cleanly, that is by returning from main().