Category:68000 Assembly: Difference between revisions

m
m (→‎Kernel-Defined Traps: Clarification)
Line 148:
===Kernel-Defined Traps===
Depending on the hardware, certain traps are built-in to perform certain tasks, such as reading a keyboard or mouse, or are user-defined. To create your own trap routine, you'll need to first write the routine, then store its address in the corresponding trap number. Trap 0 is stored at $000080, Trap 1 at $000084, and so on. The overflow trap is stored at address $00001C. If your assembler supports labels, you can simply specify the label at the trap data block.
 
<lang 68000devpac>org $000080
DC.L Trap0
DC.L Trap1
DC.L Trap2
DC.L Trap3
DC.L IllegalInstructionHandler
DC.L DivideByZeroHandler</lang>
etc.
 
Keep in mind that this table is very tightly packed. There is no room for any code here- just the memory addresses where your routines are stored. To my knowledge, the CPU can't "remember" what trap was called after doing so. Therefore you can't just point all traps to the same error handler, you'll need a slightly different one for each.
 
==Alignment==
1,489

edits