1 |
|
* |
2 |
|
* asm_support.asm - AmigaOS utility functions in assembly language |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2001 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 |
28 |
|
XDEF _AtomicAnd |
29 |
|
XDEF _AtomicOr |
30 |
|
XDEF _MoveVBR |
31 |
+ |
XDEF _DisableSuperBypass |
32 |
|
XDEF _Execute68k |
33 |
|
XDEF _Execute68kTrap |
34 |
|
XDEF _TrapHandlerAsm |
48 |
|
XREF _MainTask |
49 |
|
XREF _SysBase |
50 |
|
XREF _quit_emulator |
50 |
– |
XREF _kprintf |
51 |
|
|
52 |
|
SECTION text,CODE |
53 |
|
|
54 |
+ |
MACHINE 68020 |
55 |
+ |
|
56 |
|
* |
57 |
|
* Atomic bit operations (don't trust the compiler) |
58 |
|
* |
110 |
|
rte |
111 |
|
|
112 |
|
* |
113 |
+ |
* Disable 68060 Super Bypass mode |
114 |
+ |
* |
115 |
+ |
|
116 |
+ |
_DisableSuperBypass |
117 |
+ |
movem.l d0-d1/a0-a1/a5-a6,-(sp) |
118 |
+ |
move.l _SysBase,a6 |
119 |
+ |
|
120 |
+ |
lea dissb,a5 |
121 |
+ |
JSRLIB Supervisor |
122 |
+ |
|
123 |
+ |
movem.l (sp)+,d0-d1/a0-a1/a5-a6 |
124 |
+ |
rts |
125 |
+ |
|
126 |
+ |
MACHINE 68060 |
127 |
+ |
|
128 |
+ |
dissb movec pcr,d0 |
129 |
+ |
bset #5,d0 |
130 |
+ |
movec d0,pcr |
131 |
+ |
rte |
132 |
+ |
|
133 |
+ |
MACHINE 68020 |
134 |
+ |
|
135 |
+ |
* |
136 |
|
* Execute 68k subroutine (must be ended with rts) |
137 |
|
* r->a[7] and r->sr are unused! |
138 |
|
* |
321 |
|
cmp.l #47,(sp) |
322 |
|
ble doTrapXX ; Vector 32-47 : TRAP #0 - 15 Instruction Vectors |
323 |
|
|
324 |
< |
1$: move.l _OldTrapHandler,-(sp) ;No, jump to old trap handler |
324 |
> |
1$ move.l _OldTrapHandler,-(sp) ;No, jump to old trap handler |
325 |
|
rts |
326 |
|
|
327 |
|
* |
328 |
|
* TRAP #0 - 15 Instruction Vectors |
329 |
|
* |
330 |
|
|
331 |
< |
doTrapXX: move.l a0,(sp) ;Save a0 |
331 |
> |
doTrapXX move.l a0,(sp) ;Save a0 |
332 |
|
move.l usp,a0 ;Get user stack pointer |
333 |
|
move.l 2*4(sp),-(a0) ;Copy 4-word stack frame to user stack |
334 |
|
move.l 1*4(sp),-(a0) |
346 |
|
* trace Vector |
347 |
|
* |
348 |
|
|
349 |
< |
dotrace: move.l a0,(sp) ;Save a0 |
349 |
> |
dotrace move.l a0,(sp) ;Save a0 |
350 |
|
|
351 |
|
move.l usp,a0 ;Get user stack pointer |
352 |
|
move.l 3*4(sp),-(a0) ;Copy 6-word stack frame to user stack |
376 |
|
addq.l #8,sp ;Remove exception frame from supervisor stack |
377 |
|
andi #$d8ff,sr ;Switch to user mode, enable interrupts |
378 |
|
|
354 |
– |
IFNE 0 |
355 |
– |
|
356 |
– |
; move.w ([2,sp]),($3800) |
357 |
– |
|
358 |
– |
cmp.w #$a9c3,([2,sp]) |
359 |
– |
bne 1$ |
360 |
– |
|
361 |
– |
move.l d0,-(sp) |
362 |
– |
move.l a0,-(sp) |
363 |
– |
pea afmt(pc) |
364 |
– |
jsr _kprintf |
365 |
– |
lea 3*4(sp),sp |
366 |
– |
1$: |
367 |
– |
ENDC |
368 |
– |
|
379 |
|
move.l $28.w,-(sp) ;Jump to MacOS exception handler |
380 |
|
rts |
381 |
|
|
372 |
– |
afmt: dc.b 'a0=%08lx d0=%08lx\n',0 |
373 |
– |
cnop 0,4 |
374 |
– |
|
382 |
|
* |
383 |
|
* Illegal address handler |
384 |
|
* |
385 |
|
|
386 |
< |
doilladdr: move.l a0,(sp) ;Save a0 |
386 |
> |
doilladdr move.l a0,(sp) ;Save a0 |
387 |
|
|
388 |
|
move.l usp,a0 ;Get user stack pointer |
389 |
|
move.l 3*4(sp),-(a0) ;Copy 6-word stack frame to user stack |
404 |
|
* to execute extended opcodes (see emul_op.h) |
405 |
|
* |
406 |
|
|
407 |
< |
doillinstr |
401 |
< |
movem.l a0/d0,-(sp) |
407 |
> |
doillinstr movem.l a0/d0,-(sp) |
408 |
|
move.w ([6+2*4,sp]),d0 |
409 |
|
and.w #$ff00,d0 |
410 |
|
cmp.w #$7100,d0 |
424 |
|
move.l $10.w,-(sp) ;Jump to MacOS exception handler |
425 |
|
rts |
426 |
|
|
427 |
< |
1$: |
422 |
< |
move.l a6,(sp) ;Save a6 |
427 |
> |
1$ move.l a6,(sp) ;Save a6 |
428 |
|
move.l usp,a6 ;Get user stack pointer |
429 |
|
|
430 |
|
move.l a6,-10(a6) ;Push USP (a7) |
722 |
|
rte |
723 |
|
|
724 |
|
; fsave xxx(a5) +jl+ |
725 |
< |
fsavea5: move.l (sp),d0 ;Restore d0 |
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 |
751 |
|
lea 16+4(sp),a1 ; destination address (in supervisor stack) |
752 |
|
bra 1$ |
753 |
|
|
754 |
< |
2$: move.w (a0)+,(a1)+ ; copy additional stack words back to supervisor stack |
755 |
< |
1$: dbf d0,2$ |
754 |
> |
2$ move.w (a0)+,(a1)+ ; copy additional stack words back to supervisor stack |
755 |
> |
1$ dbf d0,2$ |
756 |
|
|
757 |
|
move.l a0,usp ;Update USP |
758 |
|
movem.l (sp)+,a0/a1 ;Restore a0 and a1 |
956 |
|
rte |
957 |
|
|
958 |
|
; movec sfc,d1 +jl+ |
959 |
< |
movecsfcd1: move.l (sp)+,d0 ;Restore d0 |
959 |
> |
movecsfcd1 move.l (sp)+,d0 ;Restore d0 |
960 |
|
moveq #0,d1 |
961 |
|
addq.l #4,2(sp) |
962 |
|
rte |
963 |
|
|
964 |
|
; movec dfc,d1 +jl+ |
965 |
< |
movecdfcd1: move.l (sp)+,d0 ;Restore d0 |
965 |
> |
movecdfcd1 move.l (sp)+,d0 ;Restore d0 |
966 |
|
moveq #0,d1 |
967 |
|
addq.l #4,2(sp) |
968 |
|
rte |
969 |
|
|
970 |
< |
movecurpd0: ; movec urp,d0 +jl+ |
971 |
< |
movecsrpd0: ; movec srp,d0 |
972 |
< |
movecitt0d0: ; movec itt0,d0 |
973 |
< |
movecitt1d0: ; movec itt1,d0 |
974 |
< |
movecdtt0d0: ; movec dtt0,d0 |
975 |
< |
movecdtt1d0: ; movec dtt1,d0 |
970 |
> |
movecurpd0 ; movec urp,d0 +jl+ |
971 |
> |
movecsrpd0 ; movec srp,d0 |
972 |
> |
movecitt0d0 ; movec itt0,d0 |
973 |
> |
movecitt1d0 ; movec itt1,d0 |
974 |
> |
movecdtt0d0 ; movec dtt0,d0 |
975 |
> |
movecdtt1d0 ; movec dtt1,d0 |
976 |
|
addq.l #4,sp |
977 |
|
moveq.l #0,d0 ;MMU is always off |
978 |
|
addq.l #4,2(sp) ;skip instruction |
1027 |
|
rte |
1028 |
|
|
1029 |
|
; move usp,a1 +jl+ |
1030 |
< |
moveuspa1: move.l (sp)+,d0 |
1030 |
> |
moveuspa1 move.l (sp)+,d0 |
1031 |
|
move usp,a1 |
1032 |
|
addq.l #2,2(sp) |
1033 |
|
rte |
1034 |
|
|
1035 |
|
; move usp,a0 +jl+ |
1036 |
< |
moveuspa0: move.l (sp)+,d0 |
1036 |
> |
moveuspa0 move.l (sp)+,d0 |
1037 |
|
move usp,a0 |
1038 |
|
addq.l #2,2(sp) |
1039 |
|
rte |
1040 |
|
|
1041 |
|
; move a1,usp +jl+ |
1042 |
< |
moved1usp: move.l (sp)+,d0 |
1042 |
> |
moved1usp move.l (sp)+,d0 |
1043 |
|
move a1,usp |
1044 |
|
addq.l #2,2(sp) |
1045 |
|
rte |
1048 |
|
; Trigger NMI (Pop up debugger) |
1049 |
|
; |
1050 |
|
|
1051 |
< |
_AsmTriggerNMI: |
1047 |
< |
move.l d0,-(sp) ;Save d0 |
1051 |
> |
_AsmTriggerNMI move.l d0,-(sp) ;Save d0 |
1052 |
|
move.w #$007c,-(sp) ;Yes, fake NMI stack frame |
1053 |
|
pea 1$ |
1054 |
|
move.w _EmulatedSR,d0 |