home *** CD-ROM | disk | FTP | other *** search
- How to handle resvector:
- ------------------------
-
- XBRA is a structure, which should be used by any program installing themselves
- into vectors. It allows a program to test whether it's already installed or not.
- And it also allows to untrap a routine from that vector. Unfortunately there is
- one vector you can't untrap properly: resvector.
- If you try to untrap, you can't be absolutely sure, that resvalid has its magic
- value, at least the first program that installs itself into resvector will have
- resvalid=0. So for this program it's impossible to untrap because it can't tell
- the next program that resvalid was 0. When this program is called by the OS du-
- ring the reset, it writes a wrong value to resvalid --> the routine is called
- once again and the computer probably crashes.
- My solution is quite easy: the reset routine checks whether there is another
- program installed in resvector (after the own routine) or not (so it will be the
- last one that is called by the OS). In the first case it writes $31415926 to
- resvalid (the magic), otherwise it clears resvalid.
- This guarantees that TOS calls all routines installed in resvector till the last
- one stops this procedure (by clearing resvalid):
-
- DC.L 'XBRA'
- DC.L _ID
- OLD_RESET: DC.L 0
- RESET: MOVE.W SR,-(SP)
- ORI.W #$700,SR
- MOVE.L A0,-(SP)
- MOVE.L SP,SAVE_SP_RESET
- MOVE.L $08.w,SAVE_BUS_RESET
- MOVE.L $0C.w,SAVE_ADDRESS_RESET
- MOVE.L #_RESET,$08.w
- MOVE.L #_RESET,$0C.w
- MOVE.L #$31415926,RESVALID.w
- MOVEA.L OLD_RESET(PC),A0
- MOVE.L A0,RESVECTOR.w
- CMPI.L #'XBRA',-12(A0)
- BEQ.S ANOTHER_ONE
- _RESET: CLR.L RESVALID.w
- ANOTHER_ONE: *well here you go*
- MOVE.L SAVE_ADDRESS_RESET(PC),$0C.w
- MOVE.L SAVE_BUS_RESET(PC),$08.w
- MOVEA.L SAVE_SP_RESET(PC),SP
- MOVEA.L (SP)+,A0
- MOVE.W (SP)+,SR
- JMP (A6)
-
- SAVE_BUS_RESET: DS.L 1
- SAVE_ADDRESS_RESET: DS.L 1
- SAVE_SP_RESET: DS.L 1
-
-