-
Traps in assembler
I wrote my own code to handle a halt trap. It does the same thing as a halt trap but prints my name to console to show the machine is using my trap instead. I wrote my code and loaded it at lower memory than my main program. How can I modify the trap vector in my main program so It uses my halt trap?
p.s. using LC-3 Simulator with limited instructions (16 in total)
-
I have no idea how to do this in LC-3, but the general principle is that the vector table for traps is located in a known address (in some architectures it's a fixed location, in other architectures there is a special register that points to the vector table for traps/interrupts).
You then copy the address of your function to the vector table (if you want to be able to restore, or continue with, the original vector, you would also need to keep the old vector).
--
Mats
-
Well I found where the pointer to the halt trap is in memory and overwrote it so it points to my halt trap. But i'm not sure how to actually stop the machine, because when I execute my halt trap the program just keeps executing and doesn't stop properly. How can I stop the machine?
-
Judging by:
http://highered.mcgraw-hill.com/site...tPatelAppA.pdf
Storing zero in address 0xFFFE should "kill" the processor.
--
Mats