Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
BusErrTest.a
*********************************************************************** |
*** |
*** BusErrTest |
*** |
*** Build commands: |
*** |
*** asm BusErrTest.a |
*** link BusErrTest.a.o -o BusErrTest |
*** |
*********************************************************************** |
STRING ASIS |
PRINT OFF |
INCLUDE 'Traps.a' |
INCLUDE 'QuickEqu.a' |
INCLUDE 'SysEqu.a' |
PRINT ON |
machine mc68030 |
*********************************************************************** |
UnImpTrap EQU $A89F |
HWPriv EQU $A198 |
*********************************************************************** |
InstallVector PROC EXPORT |
IMPORT OldGuy |
IMPORT BusErrProc |
move.l a0,-(sp) ;preserve reg |
lea OldGuy,a0 ;OldGuy is a place to keep the original bus error vector |
move.l 8,(a0) ;so fill it up with the vector, victor |
lea BusErrProc,a0 ;get the address of our bus error handler |
move.l a0,8 ;and install it |
move.l (sp)+,a0 ;restore reg |
outtahere |
rts |
ENDP |
*********************************************************************** |
CauseBusErr PROC EXPORT |
movem.l a0/d0,-(sp) ;preserve the register we use |
move.l #$FFFFFFFF,a0 ;this address looks pretty dangerous... |
move.b (a0),d0 |
movem.l (sp)+,a0/d0 ;restore the registers we use |
rts ;it's Miller time |
ENDP |
*********************************************************************** |
ReplaceVector PROC EXPORT |
IMPORT OldGuy |
move.l a0,-(sp) ;preserve reg |
lea 8,a0 ;point to the 680x0 bus error vector |
move.l OldGuy,(a0) ;and fill it full of the original |
move.l (sp)+,a0 ;restore reg |
rts ;system handler vector |
ENDP |
*********************************************************************** |
BusErrProc PROC EXPORT ;THIS CODE ASSUMES THE BUS ERROR |
;EXCEPTION STACK FRAME FOR THE |
;68030!!! (REF MOTOROLA 68030 USER'S |
;MANUAL PAGE 8-25) |
IMPORT OldGuy |
RegOffset EQU 4*2 |
movem.l a1/d0,-(sp) ;take only pictures, leave only footprints |
move.b 6+RegOffset(sp),d0 ;get the id nibble for the stack frame |
andi.b #$F0,d0 ;don't care 'bout the lower nibble... |
cmpi.b #$B0,d0 ;make sure it's the one we like |
bne.s NotOurs ;if not, pass it on to system handler |
bclr.b #0,$A+RegOffset(sp) ;clear DF bit of Special Status Reg |
;so that the instruction will not be re-tried |
move.l scrnbase,a1 ;let the user know we arrived by inverting |
move.w #$2ff,d0 ;a hunk o' screen |
Loop |
eori.l #$ffffffff,(a1)+ ;we do a long word at a time |
dbra d0,Loop ;till d0 goes negative |
movem.l (sp)+,a1/d0 ;clean up after ourselves |
ret rte ;and return from the exception |
NotOurs |
movem.l (sp)+,a1/d0 ;restore battered registers |
move.l OldGuy,-(sp) ;and pass control onto the system |
rts ;bus error handler |
ENDP |
*********************************************************************** |
OldGuy PROC EXPORT |
DC.L 0 ;a long word for storage |
ENDP |
theEnd PROC EXPORT |
ENDP |
END |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14