home *** CD-ROM | disk | FTP | other *** search
-
- far code
-
- public _geta4
- public __trapexception
- public __initfpu
-
- xref __oldtrap
- xref __traphandler
-
- DEFTRAP MACRO ;&signalnumber
- cmp.w \1,d0 ;compare trap number
- beq _deftrap ;branch to default traphandler
- ENDM
-
- MYTRAP MACRO ;&signalnumber
- cmp.w \1,d0 ;compare trap number
- beq _mytrap ;branch to own traphandler
- ENDM
-
- __trapexception:
- movem.l d0/a4,-(sp) ;need some registers
- jsr _geta4 ;set up a4
- move.l 8(sp),d0 ;get trap number
- DEFTRAP #1 ;define the traphandler
- DEFTRAP #2
- DEFTRAP #3
- MYTRAP #4
- MYTRAP #5
- MYTRAP #6
- DEFTRAP #7
- MYTRAP #8
- MYTRAP #9
- DEFTRAP #10
- DEFTRAP #11
- MYTRAP #12
- DEFTRAP #13
- DEFTRAP #14
- DEFTRAP #15
- MYTRAP #16
-
- _deftrap:
- move.l 4(sp),d0 ;get a4 for later
- move.l __oldtrap,4(sp) ;get regular handler
- move.l d0,a4 ;set real a4 value
- move.l (sp)+,d0 ;restore d0 contents
- rte ;jump to it
-
- _mytrap:
- move.l a0,-(sp) ;save a0
- move.l usp,a0 ;get user stack pointer
- move.l 18(sp),-(a0) ;save old pc
- move.w 14(sp),-(a0) ;save old sr
- movem.l d0-d7/a0-a6,-(a0) ;save old registers
- movem.l (sp)+,d1/d2/d3 ;restore d0/a0/a4
- move.l d1,(a0) ;set d0
- move.l d2,32(a0) ;set a0
- move.l d3,48(a0) ;set a4
- move.l d0,-(a0) ;pass trap number on stack
- lea _conttrap,a1 ;get return in case they want to continue
- move.l a1,-(a0) ;set return address
- move.l a0,usp ;set new user stack pointer
- lea __traphandler,a0 ;get trap handler
- move.l a0,6(sp) ;modify rte address
- addq #4,sp ;remove trap #
- rte ;go and do the handler
-
- _conttrap:
- add.w #4,sp ;pop arg
- movem.l (sp)+,d0-d7/a0-a6 ;restore old registers
- move.w (sp)+,ccr ;restore old condition codes
- rts ;and continue where we left off
-
- __initfpu:
- mc68881
-
- fmove.l FPCR,d0
- or.w #$1400,d0
- fmove.l d0,FPCR
- rts
-