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-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 |
28 |
|
XDEF _AtomicAnd |
29 |
|
XDEF _AtomicOr |
30 |
|
XDEF _MoveVBR |
31 |
< |
XDEF _TimevalTo64 |
32 |
< |
XDEF _TimevalToMacTime |
31 |
> |
XDEF _DisableSuperBypass |
32 |
|
XDEF _Execute68k |
33 |
|
XDEF _Execute68kTrap |
34 |
|
XDEF _TrapHandlerAsm |
35 |
|
XDEF _ExceptionHandlerAsm |
36 |
< |
XDEF _Scod060Patch1 |
38 |
< |
XDEF _Scod060Patch2 |
39 |
< |
XDEF _ThInitFPUPatch |
36 |
> |
XDEF _AsmTriggerNMI |
37 |
|
|
38 |
|
XREF _OldTrapHandler |
39 |
|
XREF _OldExceptionHandler |
48 |
|
|
49 |
|
SECTION text,CODE |
50 |
|
|
51 |
+ |
MACHINE 68020 |
52 |
+ |
|
53 |
|
* |
54 |
|
* Atomic bit operations (don't trust the compiler) |
55 |
|
* |
107 |
|
rte |
108 |
|
|
109 |
|
* |
110 |
< |
* Convert timeval to 64 bit microseconds |
110 |
> |
* Disable 68060 Super Bypass mode |
111 |
|
* |
112 |
|
|
113 |
< |
_TimevalTo64 move.l 4(sp),a0 ;Pointer to timeval |
114 |
< |
move.l 8(sp),a1 ;Pointer to high longword of result, low longword is returned in d0 |
115 |
< |
|
117 |
< |
move.l d2,-(sp) |
113 |
> |
_DisableSuperBypass |
114 |
> |
movem.l d0-d1/a0-a1/a5-a6,-(sp) |
115 |
> |
move.l _SysBase,a6 |
116 |
|
|
117 |
< |
move.l TV_SECS(a0),d0 ;Convert to 64 bit microseconds |
118 |
< |
mulu.l #1000000,d1:d0 |
121 |
< |
add.l TV_MICRO(a0),d0 |
122 |
< |
moveq #0,d2 |
123 |
< |
addx.l d2,d1 |
124 |
< |
move.l d1,(a1) |
117 |
> |
lea dissb,a5 |
118 |
> |
JSRLIB Supervisor |
119 |
|
|
120 |
< |
move.l (sp)+,d2 |
120 |
> |
movem.l (sp)+,d0-d1/a0-a1/a5-a6 |
121 |
|
rts |
122 |
|
|
123 |
< |
* |
130 |
< |
* Convert timeval to Mac time value (>0: milliseconds, <0: microseconds) |
131 |
< |
* |
132 |
< |
|
133 |
< |
_TimevalToMacTime |
134 |
< |
move.l 4(sp),a0 ;Pointer to timeval |
123 |
> |
MACHINE 68060 |
124 |
|
|
125 |
< |
move.l d2,-(sp) |
126 |
< |
|
127 |
< |
move.l TV_SECS(a0),d0 ;Convert to 64 bit microseconds |
128 |
< |
mulu.l #1000000,d1:d0 |
140 |
< |
add.l TV_MICRO(a0),d0 |
141 |
< |
moveq #0,d2 |
142 |
< |
addx.l d2,d1 |
143 |
< |
|
144 |
< |
tst.l d1 ;Too large for 32 bit microseconds? |
145 |
< |
bne.s 1$ |
146 |
< |
cmp.l #$7fffffff,d0 |
147 |
< |
bhi.s 1$ |
148 |
< |
|
149 |
< |
neg.l d0 ;No, return negative microseconds |
150 |
< |
bra.s 2$ |
151 |
< |
|
152 |
< |
1$ divu.l #1000,d1:d0 ;Yes, return milliseconds |
125 |
> |
dissb movec pcr,d0 |
126 |
> |
bset #5,d0 |
127 |
> |
movec d0,pcr |
128 |
> |
rte |
129 |
|
|
130 |
< |
2$ move.l (sp)+,d2 |
155 |
< |
rts |
130 |
> |
MACHINE 68020 |
131 |
|
|
132 |
|
* |
133 |
|
* Execute 68k subroutine (must be ended with rts) |
207 |
|
pea 1$ |
208 |
|
move.w _EmulatedSR,d0 |
209 |
|
move.w d0,-(sp) |
210 |
< |
or.w #$0100,d0 ;Set interrupt level in SR |
210 |
> |
or.w #$2100,d0 ;Set interrupt level in SR, enter (virtual) supervisor mode |
211 |
|
move.w d0,_EmulatedSR |
212 |
< |
move.l $64.w,a0 ;Jump to MacOS interrupt handler |
213 |
< |
jmp (a0) |
212 |
> |
move.l $64.w,-(sp) ;Jump to MacOS interrupt handler |
213 |
> |
rts |
214 |
|
|
215 |
|
1$ move.l (sp)+,d0 ;Restore d0 |
216 |
|
rts |
241 |
|
rts |
242 |
|
|
243 |
|
* |
244 |
< |
* Process Manager 68060 FPU patches |
244 |
> |
* Trap handler of main task |
245 |
|
* |
246 |
|
|
247 |
< |
_Scod060Patch1 fsave -(sp) ;Save FPU state |
248 |
< |
tst.b 2(sp) ;Null? |
249 |
< |
beq.s 1$ |
250 |
< |
fmovem.x fp0-fp7,-(sp) ;No, save FPU registers |
251 |
< |
fmove.l fpiar,-(sp) |
252 |
< |
fmove.l fpsr,-(sp) |
253 |
< |
fmove.l fpcr,-(sp) |
254 |
< |
pea -1 ;Push "FPU state saved" flag |
255 |
< |
1$ move.l d1,-(sp) |
256 |
< |
move.l d0,-(sp) |
257 |
< |
bsr.s 3$ ;Switch integer registers and stack |
258 |
< |
addq.l #8,sp |
259 |
< |
tst.b 2(sp) ;New FPU state null or "FPU state saved" flag set? |
260 |
< |
beq.s 2$ |
261 |
< |
addq.l #4,sp ;Flag set, skip it |
262 |
< |
fmove.l (sp)+,fpcr ;Restore FPU registers and state |
263 |
< |
fmove.l (sp)+,fpsr |
264 |
< |
fmove.l (sp)+,fpiar |
290 |
< |
fmovem.x (sp)+,fp0-fp7 |
291 |
< |
2$ frestore (sp)+ |
292 |
< |
movem.l (sp)+,d0-d1 |
293 |
< |
rts |
294 |
< |
|
295 |
< |
3$ move.l 4(sp),a0 ;Switch integer registers and stack |
296 |
< |
move sr,-(sp) |
297 |
< |
movem.l d2-d7/a2-a6,-(sp) |
298 |
< |
cmp.w #0,a0 |
299 |
< |
beq.s 4$ |
300 |
< |
move.l sp,(a0) |
301 |
< |
4$ move.l $36(sp),a0 |
302 |
< |
movem.l (a0)+,d2-d7/a2-a6 |
303 |
< |
move (a0)+,sr |
304 |
< |
move.l a0,sp |
305 |
< |
rts |
306 |
< |
|
307 |
< |
_Scod060Patch2 move.l d0,-(sp) ;Create 68060 null frame on stack |
308 |
< |
move.l d0,-(sp) |
309 |
< |
move.l d0,-(sp) |
310 |
< |
frestore (sp)+ ;and load it |
247 |
> |
_TrapHandlerAsm: |
248 |
> |
cmp.l #4,(sp) ;Illegal instruction? |
249 |
> |
beq.s doillinstr |
250 |
> |
cmp.l #10,(sp) ;A-Line exception? |
251 |
> |
beq.s doaline |
252 |
> |
cmp.l #8,(sp) ;Privilege violation? |
253 |
> |
beq.s doprivviol |
254 |
> |
cmp.l #9,(sp) ;Trace? |
255 |
> |
beq dotrace |
256 |
> |
cmp.l #3,(sp) ;Illegal Address? |
257 |
> |
beq.s doilladdr |
258 |
> |
|
259 |
> |
cmp.l #32,(sp) |
260 |
> |
blt 1$ |
261 |
> |
cmp.l #47,(sp) |
262 |
> |
ble doTrapXX ; Vector 32-47 : TRAP #0 - 15 Instruction Vectors |
263 |
> |
|
264 |
> |
1$ move.l _OldTrapHandler,-(sp) ;No, jump to old trap handler |
265 |
|
rts |
266 |
|
|
267 |
|
* |
268 |
< |
* Thread Manager 68060 FPU patches |
268 |
> |
* TRAP #0 - 15 Instruction Vectors |
269 |
|
* |
270 |
|
|
271 |
< |
_ThInitFPUPatch tst.b $40(a4) |
272 |
< |
bne.s 1$ |
273 |
< |
moveq #0,d0 ;Create 68060 null frame on stack |
274 |
< |
move.l d0,-(a3) |
275 |
< |
move.l d0,-(a3) |
276 |
< |
move.l d0,-(a3) |
277 |
< |
1$ rts |
271 |
> |
doTrapXX move.l a0,(sp) ;Save a0 |
272 |
> |
move.l usp,a0 ;Get user stack pointer |
273 |
> |
move.l 2*4(sp),-(a0) ;Copy 4-word stack frame to user stack |
274 |
> |
move.l 1*4(sp),-(a0) |
275 |
> |
move.l a0,usp ;Update USP |
276 |
> |
move.l (sp)+,a0 ;Restore a0 |
277 |
> |
|
278 |
> |
addq.l #4*2,sp ;Remove exception frame from supervisor stack |
279 |
> |
andi #$d8ff,sr ;Switch to user mode, enable interrupts |
280 |
> |
|
281 |
> |
move.l $2d*4.w,-(sp) ;Jump to MacOS exception handler |
282 |
> |
rts |
283 |
> |
|
284 |
|
|
285 |
|
* |
286 |
< |
* Trap handler of main task |
286 |
> |
* trace Vector |
287 |
|
* |
288 |
|
|
289 |
< |
_TrapHandlerAsm cmp.l #4,(sp) ;Illegal instruction? |
330 |
< |
beq.s doillinstr |
331 |
< |
cmp.l #10,(sp) ;A-Line exception? |
332 |
< |
beq.s doaline |
333 |
< |
cmp.l #8,(sp) ;Privilege violation? |
334 |
< |
beq.s doprivviol |
289 |
> |
dotrace move.l a0,(sp) ;Save a0 |
290 |
|
|
291 |
< |
move.l _OldTrapHandler,-(sp) ;No, jump to old trap handler |
291 |
> |
move.l usp,a0 ;Get user stack pointer |
292 |
> |
move.l 3*4(sp),-(a0) ;Copy 6-word stack frame to user stack |
293 |
> |
move.l 2*4(sp),-(a0) |
294 |
> |
move.l 1*4(sp),-(a0) |
295 |
> |
move.l a0,usp ;Update USP |
296 |
> |
move.l (sp)+,a0 ;Restore a0 |
297 |
> |
|
298 |
> |
lea 6*2(sp),sp ;Remove exception frame from supervisor stack |
299 |
> |
andi #$18ff,sr ;Switch to user mode, enable interrupts, disable trace |
300 |
> |
|
301 |
> |
move.l $24.w,-(sp) ;Jump to MacOS exception handler |
302 |
|
rts |
303 |
|
|
304 |
+ |
|
305 |
|
* |
306 |
|
* A-Line handler: call MacOS A-Line handler |
307 |
|
* |
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 |
|
|
324 |
|
* |
325 |
+ |
* Illegal address handler |
326 |
+ |
* |
327 |
+ |
|
328 |
+ |
doilladdr move.l a0,(sp) ;Save a0 |
329 |
+ |
|
330 |
+ |
move.l usp,a0 ;Get user stack pointer |
331 |
+ |
move.l 3*4(sp),-(a0) ;Copy 6-word stack frame to user stack |
332 |
+ |
move.l 2*4(sp),-(a0) |
333 |
+ |
move.l 1*4(sp),-(a0) |
334 |
+ |
move.l a0,usp ;Update USP |
335 |
+ |
move.l (sp)+,a0 ;Restore a0 |
336 |
+ |
|
337 |
+ |
lea 6*2(sp),sp ;Remove exception frame from supervisor stack |
338 |
+ |
andi #$d8ff,sr ;Switch to user mode, enable interrupts |
339 |
+ |
|
340 |
+ |
move.l $0c.w,-(sp) ;Jump to MacOS exception handler |
341 |
+ |
rts |
342 |
+ |
|
343 |
+ |
|
344 |
+ |
* |
345 |
|
* Illegal instruction handler: call IllInstrHandler() (which calls EmulOp()) |
346 |
|
* to execute extended opcodes (see emul_op.h) |
347 |
|
* |
348 |
|
|
349 |
< |
doillinstr move.l a6,(sp) ;Save a6 |
349 |
> |
doillinstr movem.l a0/d0,-(sp) |
350 |
> |
move.w ([6+2*4,sp]),d0 |
351 |
> |
and.w #$ff00,d0 |
352 |
> |
cmp.w #$7100,d0 |
353 |
> |
movem.l (sp)+,a0/d0 |
354 |
> |
beq 1$ |
355 |
> |
|
356 |
> |
move.l a0,(sp) ;Save a0 |
357 |
> |
move.l usp,a0 ;Get user stack pointer |
358 |
> |
move.l 8(sp),-(a0) ;Copy stack frame to user stack |
359 |
> |
move.l 4(sp),-(a0) |
360 |
> |
move.l a0,usp ;Update USP |
361 |
> |
move.l (sp)+,a0 ;Restore a0 |
362 |
> |
|
363 |
> |
add.w #3*4,sp ;Remove exception frame from supervisor stack |
364 |
> |
andi #$d8ff,sr ;Switch to user mode, enable interrupts |
365 |
> |
|
366 |
> |
move.l $10.w,-(sp) ;Jump to MacOS exception handler |
367 |
> |
rts |
368 |
> |
|
369 |
> |
1$ move.l a6,(sp) ;Save a6 |
370 |
|
move.l usp,a6 ;Get user stack pointer |
371 |
|
|
372 |
|
move.l a6,-10(a6) ;Push USP (a7) |
421 |
|
cmp.w #$40d0,d0 ;move sr,(a0)? |
422 |
|
beq movefromsra0 |
423 |
|
cmp.w #$40d7,d0 ;move sr,(sp)? |
424 |
< |
beq movefromsra0 |
424 |
> |
beq movefromsrsp |
425 |
|
|
426 |
|
cmp.w #$f327,d0 ;fsave -(sp)? |
427 |
|
beq fsavepush |
428 |
|
cmp.w #$f35f,d0 ;frestore (sp)+? |
429 |
|
beq frestorepop |
430 |
+ |
cmp.w #$f32d,d0 ;fsave xxx(a5) ? |
431 |
+ |
beq fsavea5 |
432 |
+ |
cmp.w #$f36d,d0 ;frestore xxx(a5) ? |
433 |
+ |
beq frestorea5 |
434 |
|
|
435 |
|
cmp.w #$4e73,d0 ;rte? |
436 |
|
beq pvrte |
479 |
|
cmp.w #$f4f8,d0 ;cpusha dc/ic? |
480 |
|
beq cpushadcic |
481 |
|
|
482 |
+ |
cmp.w #$4e69,d0 ;move usp,a1 |
483 |
+ |
beq moveuspa1 |
484 |
+ |
cmp.w #$4e68,d0 ;move usp,a0 |
485 |
+ |
beq moveuspa0 |
486 |
+ |
|
487 |
+ |
cmp.w #$4e61,d0 ;move a1,usp |
488 |
+ |
beq moved1usp |
489 |
+ |
|
490 |
|
pv_unhandled move.l (sp),d0 ;Unhandled instruction, jump to handler in main.cpp |
491 |
|
move.l a6,(sp) ;Save a6 |
492 |
|
move.l usp,a6 ;Get user stack pointer |
528 |
|
move.w (a0)+,d0 ;Get SR from user stack |
529 |
|
move.w d0,8(sp) ;Store into CCR on exception stack frame |
530 |
|
and.w #$00ff,8(sp) |
531 |
< |
and.w #$2700,d0 ;Extract supervisor bits |
531 |
> |
and.w #$e700,d0 ;Extract supervisor bits |
532 |
|
move.w d0,_EmulatedSR ;And save them |
533 |
|
|
534 |
|
and.w #$0700,d0 ;Rethrow exception if interrupts are pending and reenabled |
554 |
|
or.w ([6,sp],2),d0 ;Or with immediate value |
555 |
|
move.w d0,4(sp) ;Store into CCR on stack |
556 |
|
and.w #$00ff,4(sp) |
557 |
< |
and.w #$2700,d0 ;Extract supervisor bits |
557 |
> |
and.w #$e700,d0 ;Extract supervisor bits |
558 |
|
move.w d0,_EmulatedSR ;And save them |
559 |
|
move.l (sp)+,d0 ;Restore d0 |
560 |
|
addq.l #4,2(sp) ;Skip instruction |
566 |
|
and.w ([6,sp],2),d0 ;And with immediate value |
567 |
|
storesr4 move.w d0,4(sp) ;Store into CCR on stack |
568 |
|
and.w #$00ff,4(sp) |
569 |
< |
and.w #$2700,d0 ;Extract supervisor bits |
569 |
> |
and.w #$e700,d0 ;Extract supervisor bits |
570 |
|
move.w d0,_EmulatedSR ;And save them |
571 |
|
|
572 |
|
and.w #$0700,d0 ;Rethrow exception if interrupts are pending and reenabled |
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 |
< |
; rte (only handles format 0) |
667 |
< |
pvrte move.l a0,-(sp) ;Save a0 |
666 |
> |
; frestore xxx(a5) |
667 |
> |
frestorea5 move.l (sp),d0 ;Restore d0 |
668 |
> |
move.l a0,(sp) ;Save a0 |
669 |
> |
move.l (sp)+,a0 ;Restore a0 |
670 |
> |
addq.l #4,2(sp) ;Skip instruction |
671 |
> |
rte |
672 |
> |
|
673 |
> |
; rte |
674 |
> |
pvrte movem.l a0/a1,-(sp) ;Save a0 and a1 |
675 |
|
move.l usp,a0 ;Get user stack pointer |
676 |
+ |
|
677 |
|
move.w (a0)+,d0 ;Get SR from user stack |
678 |
< |
move.w d0,8(sp) ;Store into CCR on exception stack frame |
679 |
< |
and.w #$00ff,8(sp) |
680 |
< |
and.w #$2700,d0 ;Extract supervisor bits |
678 |
> |
move.w d0,8+4(sp) ;Store into CCR on exception stack frame |
679 |
> |
and.w #$c0ff,8+4(sp) |
680 |
> |
and.w #$e700,d0 ;Extract supervisor bits |
681 |
|
move.w d0,_EmulatedSR ;And save them |
682 |
< |
move.l (a0)+,10(sp) ;Store return address in exception stack frame |
683 |
< |
addq.l #2,a0 ;Skip format word |
682 |
> |
move.l (a0)+,10+4(sp) ;Store return address in exception stack frame |
683 |
> |
|
684 |
> |
move.w (a0)+,d0 ;get format word |
685 |
> |
lsr.w #7,d0 ;get stack frame Id |
686 |
> |
lsr.w #4,d0 |
687 |
> |
and.w #$001e,d0 |
688 |
> |
move.w (StackFormatTable,pc,d0.w),d0 ; get total stack frame length |
689 |
> |
subq.w #4,d0 ; count only extra words |
690 |
> |
lea 16+4(sp),a1 ; destination address (in supervisor stack) |
691 |
> |
bra 1$ |
692 |
> |
|
693 |
> |
2$ move.w (a0)+,(a1)+ ; copy additional stack words back to supervisor stack |
694 |
> |
1$ dbf d0,2$ |
695 |
> |
|
696 |
|
move.l a0,usp ;Update USP |
697 |
< |
move.l (sp)+,a0 ;Restore a0 |
697 |
> |
movem.l (sp)+,a0/a1 ;Restore a0 and a1 |
698 |
|
move.l (sp)+,d0 ;Restore d0 |
699 |
|
rte |
700 |
|
|
701 |
+ |
; sizes of exceptions stack frames |
702 |
+ |
StackFormatTable: |
703 |
+ |
dc.w 4 ; Four-word stack frame, format $0 |
704 |
+ |
dc.w 4 ; Throwaway four-word stack frame, format $1 |
705 |
+ |
dc.w 6 ; Six-word stack frame, format $2 |
706 |
+ |
dc.w 6 ; MC68040 floating-point post-instruction stack frame, format $3 |
707 |
+ |
dc.w 8 ; MC68EC040 and MC68LC040 floating-point unimplemented stack frame, format $4 |
708 |
+ |
dc.w 4 ; Format $5 |
709 |
+ |
dc.w 4 ; Format $6 |
710 |
+ |
dc.w 30 ; MC68040 access error stack frame, Format $7 |
711 |
+ |
dc.w 29 ; MC68010 bus and address error stack frame, format $8 |
712 |
+ |
dc.w 10 ; MC68020 and MC68030 coprocessor mid-instruction stack frame, format $9 |
713 |
+ |
dc.w 16 ; MC68020 and MC68030 short bus cycle stack frame, format $a |
714 |
+ |
dc.w 46 ; MC68020 and MC68030 long bus cycle stack frame, format $b |
715 |
+ |
dc.w 12 ; CPU32 bus error for prefetches and operands stack frame, format $c |
716 |
+ |
dc.w 4 ; Format $d |
717 |
+ |
dc.w 4 ; Format $e |
718 |
+ |
dc.w 4 ; Format $f |
719 |
+ |
|
720 |
|
; move sr,dx |
721 |
|
movefromsrd0 addq.l #4,sp ;Skip saved d0 |
722 |
|
moveq #0,d0 |
778 |
|
movetosrd0 move.l (sp),d0 |
779 |
|
storesr2 move.w d0,4(sp) |
780 |
|
and.w #$00ff,4(sp) |
781 |
< |
and.w #$2700,d0 |
781 |
> |
and.w #$e700,d0 |
782 |
|
move.w d0,_EmulatedSR |
783 |
|
|
784 |
|
and.w #$0700,d0 ;Rethrow exception if interrupts are pending and reenabled |
823 |
|
beq.s movecvbra0 |
824 |
|
cmp.w #$9801,d0 ;movec vbr,a1? |
825 |
|
beq.s movecvbra1 |
826 |
+ |
cmp.w #$1801,d0 ;movec vbr,d1? |
827 |
+ |
beq movecvbrd1 |
828 |
|
cmp.w #$0002,d0 ;movec cacr,d0? |
829 |
|
beq.s moveccacrd0 |
830 |
|
cmp.w #$1002,d0 ;movec cacr,d1? |
833 |
|
beq.s movectcd0 |
834 |
|
cmp.w #$1003,d0 ;movec tc,d1? |
835 |
|
beq.s movectcd1 |
836 |
+ |
cmp.w #$1000,d0 ;movec sfc,d1? |
837 |
+ |
beq movecsfcd1 |
838 |
+ |
cmp.w #$1001,d0 ;movec dfc,d1? |
839 |
+ |
beq movecdfcd1 |
840 |
+ |
cmp.w #$0806,d0 ;movec urp,d0? |
841 |
+ |
beq movecurpd0 |
842 |
+ |
cmp.w #$0807,d0 ;movec srp,d0? |
843 |
+ |
beq.s movecsrpd0 |
844 |
+ |
cmp.w #$0004,d0 ;movec itt0,d0 |
845 |
+ |
beq.s movecitt0d0 |
846 |
+ |
cmp.w #$0005,d0 ;movec itt1,d0 |
847 |
+ |
beq.s movecitt1d0 |
848 |
+ |
cmp.w #$0006,d0 ;movec dtt0,d0 |
849 |
+ |
beq.s movecdtt0d0 |
850 |
+ |
cmp.w #$0007,d0 ;movec dtt1,d0 |
851 |
+ |
beq.s movecdtt1d0 |
852 |
|
|
853 |
|
bra pv_unhandled |
854 |
|
|
876 |
|
addq.l #4,2(sp) |
877 |
|
rte |
878 |
|
|
879 |
+ |
; movec vbr,d1 |
880 |
+ |
movecvbrd1 move.l (sp)+,d0 |
881 |
+ |
moveq.l #0,d1 ;VBR always appears to be at 0 |
882 |
+ |
addq.l #4,2(sp) |
883 |
+ |
rte |
884 |
+ |
|
885 |
|
; movec tc,d0 |
886 |
|
movectcd0 addq.l #4,sp |
887 |
|
moveq #0,d0 ;MMU is always off |
888 |
|
addq.l #4,2(sp) |
889 |
|
rte |
890 |
|
|
891 |
< |
; movec tc,d1 |
892 |
< |
movectcd1 addq.l #4,sp |
891 |
> |
; movec tc,d1 +jl+ |
892 |
> |
movectcd1 move.l (sp)+,d0 ;Restore d0 |
893 |
|
moveq #0,d1 ;MMU is always off |
894 |
|
addq.l #4,2(sp) |
895 |
|
rte |
896 |
|
|
897 |
+ |
; movec sfc,d1 +jl+ |
898 |
+ |
movecsfcd1 move.l (sp)+,d0 ;Restore d0 |
899 |
+ |
moveq #0,d1 |
900 |
+ |
addq.l #4,2(sp) |
901 |
+ |
rte |
902 |
+ |
|
903 |
+ |
; movec dfc,d1 +jl+ |
904 |
+ |
movecdfcd1 move.l (sp)+,d0 ;Restore d0 |
905 |
+ |
moveq #0,d1 |
906 |
+ |
addq.l #4,2(sp) |
907 |
+ |
rte |
908 |
+ |
|
909 |
+ |
movecurpd0 ; movec urp,d0 +jl+ |
910 |
+ |
movecsrpd0 ; movec srp,d0 |
911 |
+ |
movecitt0d0 ; movec itt0,d0 |
912 |
+ |
movecitt1d0 ; movec itt1,d0 |
913 |
+ |
movecdtt0d0 ; movec dtt0,d0 |
914 |
+ |
movecdtt1d0 ; movec dtt1,d0 |
915 |
+ |
addq.l #4,sp |
916 |
+ |
moveq.l #0,d0 ;MMU is always off |
917 |
+ |
addq.l #4,2(sp) ;skip instruction |
918 |
+ |
rte |
919 |
+ |
|
920 |
|
; movec x,cr |
921 |
|
movectocr move.w ([6,sp],2),d0 ;Get next instruction word |
922 |
|
|
923 |
|
cmp.w #$0801,d0 ;movec d0,vbr? |
924 |
|
beq.s movectovbr |
925 |
+ |
cmp.w #$1801,d0 ;movec d1,vbr? |
926 |
+ |
beq.s movectovbr |
927 |
|
cmp.w #$0002,d0 ;movec d0,cacr? |
928 |
|
beq.s movectocacr |
929 |
|
cmp.w #$1002,d0 ;movec d1,cacr? |
930 |
|
beq.s movectocacr |
931 |
+ |
cmp.w #$1000,d0 ;movec d1,sfc? |
932 |
+ |
beq.s movectoxfc |
933 |
+ |
cmp.w #$1001,d0 ;movec d1,dfc? |
934 |
+ |
beq.s movectoxfc |
935 |
|
|
936 |
|
bra pv_unhandled |
937 |
|
|
949 |
|
addq.l #4,2(sp) |
950 |
|
rte |
951 |
|
|
952 |
+ |
; movec x,sfc |
953 |
+ |
; movec x,dfc |
954 |
+ |
movectoxfc move.l (sp)+,d0 ;Ignore moves to SFC, DFC |
955 |
+ |
addq.l #4,2(sp) |
956 |
+ |
rte |
957 |
+ |
|
958 |
|
; cpusha |
959 |
|
cpushadc |
960 |
|
cpushadcic movem.l d1/a0-a1/a6,-(sp) ;Clear caches |
965 |
|
addq.l #2,2(sp) |
966 |
|
rte |
967 |
|
|
968 |
+ |
; move usp,a1 +jl+ |
969 |
+ |
moveuspa1 move.l (sp)+,d0 |
970 |
+ |
move usp,a1 |
971 |
+ |
addq.l #2,2(sp) |
972 |
+ |
rte |
973 |
+ |
|
974 |
+ |
; move usp,a0 +jl+ |
975 |
+ |
moveuspa0 move.l (sp)+,d0 |
976 |
+ |
move usp,a0 |
977 |
+ |
addq.l #2,2(sp) |
978 |
+ |
rte |
979 |
+ |
|
980 |
+ |
; move a1,usp +jl+ |
981 |
+ |
moved1usp move.l (sp)+,d0 |
982 |
+ |
move a1,usp |
983 |
+ |
addq.l #2,2(sp) |
984 |
+ |
rte |
985 |
+ |
|
986 |
+ |
; |
987 |
+ |
; Trigger NMI (Pop up debugger) |
988 |
+ |
; |
989 |
+ |
|
990 |
+ |
_AsmTriggerNMI move.l d0,-(sp) ;Save d0 |
991 |
+ |
move.w #$007c,-(sp) ;Yes, fake NMI stack frame |
992 |
+ |
pea 1$ |
993 |
+ |
move.w _EmulatedSR,d0 |
994 |
+ |
and.w #$f8ff,d0 ;Set interrupt level in SR |
995 |
+ |
move.w d0,-(sp) |
996 |
+ |
move.w d0,_EmulatedSR |
997 |
+ |
|
998 |
+ |
move.l $7c.w,-(sp) ;Jump to MacOS NMI handler |
999 |
+ |
rts |
1000 |
+ |
|
1001 |
+ |
1$ move.l (sp)+,d0 ;Restore d0 |
1002 |
+ |
rts |
1003 |
+ |
|
1004 |
+ |
|
1005 |
|
END |