1 |
|
* |
2 |
|
* asm_support.asm - AmigaOS utility functions in assembly language |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
33 |
|
XDEF _Execute68kTrap |
34 |
|
XDEF _TrapHandlerAsm |
35 |
|
XDEF _ExceptionHandlerAsm |
36 |
– |
XDEF _Scod060Patch1 |
37 |
– |
XDEF _Scod060Patch2 |
38 |
– |
XDEF _ThInitFPUPatch |
36 |
|
XDEF _AsmTriggerNMI |
37 |
|
|
38 |
|
XREF _OldTrapHandler |
241 |
|
rts |
242 |
|
|
243 |
|
* |
247 |
– |
* Process Manager 68060 FPU patches |
248 |
– |
* |
249 |
– |
|
250 |
– |
_Scod060Patch1 fsave -(sp) ;Save FPU state |
251 |
– |
tst.b 2(sp) ;Null? |
252 |
– |
beq.s 1$ |
253 |
– |
fmovem.x fp0-fp7,-(sp) ;No, save FPU registers |
254 |
– |
fmove.l fpiar,-(sp) |
255 |
– |
fmove.l fpsr,-(sp) |
256 |
– |
fmove.l fpcr,-(sp) |
257 |
– |
pea -1 ;Push "FPU state saved" flag |
258 |
– |
1$ move.l d1,-(sp) |
259 |
– |
move.l d0,-(sp) |
260 |
– |
bsr.s 3$ ;Switch integer registers and stack |
261 |
– |
addq.l #8,sp |
262 |
– |
tst.b 2(sp) ;New FPU state null or "FPU state saved" flag set? |
263 |
– |
beq.s 2$ |
264 |
– |
addq.l #4,sp ;Flag set, skip it |
265 |
– |
fmove.l (sp)+,fpcr ;Restore FPU registers and state |
266 |
– |
fmove.l (sp)+,fpsr |
267 |
– |
fmove.l (sp)+,fpiar |
268 |
– |
fmovem.x (sp)+,fp0-fp7 |
269 |
– |
2$ frestore (sp)+ |
270 |
– |
movem.l (sp)+,d0-d1 |
271 |
– |
rts |
272 |
– |
|
273 |
– |
3$ move.l 4(sp),a0 ;Switch integer registers and stack |
274 |
– |
move sr,-(sp) |
275 |
– |
movem.l d2-d7/a2-a6,-(sp) |
276 |
– |
cmp.w #0,a0 |
277 |
– |
beq.s 4$ |
278 |
– |
move.l sp,(a0) |
279 |
– |
4$ move.l $36(sp),a0 |
280 |
– |
movem.l (a0)+,d2-d7/a2-a6 |
281 |
– |
move (a0)+,sr |
282 |
– |
move.l a0,sp |
283 |
– |
rts |
284 |
– |
|
285 |
– |
_Scod060Patch2 move.l d0,-(sp) ;Create 68060 null frame on stack |
286 |
– |
move.l d0,-(sp) |
287 |
– |
move.l d0,-(sp) |
288 |
– |
frestore (sp)+ ;and load it |
289 |
– |
rts |
290 |
– |
|
291 |
– |
* |
292 |
– |
* Thread Manager 68060 FPU patches |
293 |
– |
* |
294 |
– |
|
295 |
– |
_ThInitFPUPatch tst.b $40(a4) |
296 |
– |
bne.s 1$ |
297 |
– |
moveq #0,d0 ;Create 68060 null frame on stack |
298 |
– |
move.l d0,-(a3) |
299 |
– |
move.l d0,-(a3) |
300 |
– |
move.l d0,-(a3) |
301 |
– |
1$ rts |
302 |
– |
|
303 |
– |
* |
244 |
|
* Trap handler of main task |
245 |
|
* |
246 |
|
|
316 |
|
addq.l #8,sp ;Remove exception frame from supervisor stack |
317 |
|
andi #$d8ff,sr ;Switch to user mode, enable interrupts |
318 |
|
|
319 |
+ |
and.w #$d8ff,_EmulatedSR ;enable interrupts in EmulatedSR |
320 |
+ |
|
321 |
|
move.l $28.w,-(sp) ;Jump to MacOS exception handler |
322 |
|
rts |
323 |
|
|
637 |
|
fsavepush move.l (sp),d0 ;Restore d0 |
638 |
|
move.l a0,(sp) ;Save a0 |
639 |
|
move.l usp,a0 ;Get user stack pointer |
640 |
< |
fsave -(a0) ;Push FP state |
640 |
> |
move.l #$41000000,-(a0) ;Push idle frame |
641 |
|
move.l a0,usp ;Update USP |
642 |
|
move.l (sp)+,a0 ;Restore a0 |
643 |
|
addq.l #2,2(sp) ;Skip instruction |
644 |
|
rte |
645 |
|
|
646 |
+ |
; fsave xxx(a5) |
647 |
+ |
fsavea5 move.l (sp),d0 ;Restore d0 |
648 |
+ |
move.l a0,(sp) ;Save a0 |
649 |
+ |
move.l a5,a0 ;Get base register |
650 |
+ |
add.w ([6,sp],2),a0 ;Add offset to base register |
651 |
+ |
move.l #$41000000,(a0) ;Push idle frame |
652 |
+ |
move.l (sp)+,a0 ;Restore a0 |
653 |
+ |
addq.l #4,2(sp) ;Skip instruction |
654 |
+ |
rte |
655 |
+ |
|
656 |
|
; frestore (sp)+ |
657 |
|
frestorepop move.l (sp),d0 ;Restore d0 |
658 |
|
move.l a0,(sp) ;Save a0 |
659 |
|
move.l usp,a0 ;Get user stack pointer |
660 |
< |
frestore (a0)+ ;Restore FP state |
660 |
> |
addq.l #4,a0 ;Nothing to do... |
661 |
|
move.l a0,usp ;Update USP |
662 |
|
move.l (sp)+,a0 ;Restore a0 |
663 |
|
addq.l #2,2(sp) ;Skip instruction |
664 |
|
rte |
665 |
|
|
666 |
< |
; frestore xxx(a5) +jl+ |
666 |
> |
; frestore xxx(a5) |
667 |
|
frestorea5 move.l (sp),d0 ;Restore d0 |
668 |
|
move.l a0,(sp) ;Save a0 |
717 |
– |
move.l a5,a0 ;Get base register |
718 |
– |
add.w ([6,sp],2),a0 ;Add offset to base register |
719 |
– |
frestore (a0) ;Restore FP state from (a0) |
720 |
– |
move.l (sp)+,a0 ;Restore a0 |
721 |
– |
addq.l #4,2(sp) ;Skip instruction |
722 |
– |
rte |
723 |
– |
|
724 |
– |
; fsave xxx(a5) +jl+ |
725 |
– |
fsavea5 move.l (sp),d0 ;Restore d0 |
726 |
– |
move.l a0,(sp) ;Save a0 |
727 |
– |
move.l a5,a0 ;Get base register |
728 |
– |
add.w ([6,sp],2),a0 ;Add offset to base register |
729 |
– |
fsave (a0) ;Push FP state to (a0) |
669 |
|
move.l (sp)+,a0 ;Restore a0 |
670 |
|
addq.l #4,2(sp) ;Skip instruction |
671 |
|
rte |