47 |
|
XREF _MainTask |
48 |
|
XREF _SysBase |
49 |
|
XREF _quit_emulator |
50 |
– |
XREF _kprintf |
50 |
|
|
51 |
|
SECTION text,CODE |
52 |
|
|
184 |
|
pea 1$ |
185 |
|
move.w _EmulatedSR,d0 |
186 |
|
move.w d0,-(sp) |
187 |
< |
or.w #$0100,d0 ;Set interrupt level in SR |
187 |
> |
or.w #$2100,d0 ;Set interrupt level in SR, enter (virtual) supervisor mode |
188 |
|
move.w d0,_EmulatedSR |
189 |
|
move.l $64.w,-(sp) ;Jump to MacOS interrupt handler |
190 |
|
rts |
295 |
|
cmp.l #47,(sp) |
296 |
|
ble doTrapXX ; Vector 32-47 : TRAP #0 - 15 Instruction Vectors |
297 |
|
|
298 |
< |
1$: move.l _OldTrapHandler,-(sp) ;No, jump to old trap handler |
298 |
> |
1$ move.l _OldTrapHandler,-(sp) ;No, jump to old trap handler |
299 |
|
rts |
300 |
|
|
301 |
|
* |
302 |
|
* TRAP #0 - 15 Instruction Vectors |
303 |
|
* |
304 |
|
|
305 |
< |
doTrapXX: move.l a0,(sp) ;Save a0 |
305 |
> |
doTrapXX move.l a0,(sp) ;Save a0 |
306 |
|
move.l usp,a0 ;Get user stack pointer |
307 |
|
move.l 2*4(sp),-(a0) ;Copy 4-word stack frame to user stack |
308 |
|
move.l 1*4(sp),-(a0) |
320 |
|
* trace Vector |
321 |
|
* |
322 |
|
|
323 |
< |
dotrace: move.l a0,(sp) ;Save a0 |
323 |
> |
dotrace move.l a0,(sp) ;Save a0 |
324 |
|
|
325 |
|
move.l usp,a0 ;Get user stack pointer |
326 |
|
move.l 3*4(sp),-(a0) ;Copy 6-word stack frame to user stack |
350 |
|
addq.l #8,sp ;Remove exception frame from supervisor stack |
351 |
|
andi #$d8ff,sr ;Switch to user mode, enable interrupts |
352 |
|
|
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 |
– |
|
353 |
|
move.l $28.w,-(sp) ;Jump to MacOS exception handler |
354 |
|
rts |
355 |
|
|
372 |
– |
afmt: dc.b 'a0=%08lx d0=%08lx\n',0 |
373 |
– |
cnop 0,4 |
374 |
– |
|
356 |
|
* |
357 |
|
* Illegal address handler |
358 |
|
* |
359 |
|
|
360 |
< |
doilladdr: move.l a0,(sp) ;Save a0 |
360 |
> |
doilladdr move.l a0,(sp) ;Save a0 |
361 |
|
|
362 |
|
move.l usp,a0 ;Get user stack pointer |
363 |
|
move.l 3*4(sp),-(a0) ;Copy 6-word stack frame to user stack |
378 |
|
* to execute extended opcodes (see emul_op.h) |
379 |
|
* |
380 |
|
|
381 |
< |
doillinstr |
401 |
< |
movem.l a0/d0,-(sp) |
381 |
> |
doillinstr movem.l a0/d0,-(sp) |
382 |
|
move.w ([6+2*4,sp]),d0 |
383 |
|
and.w #$ff00,d0 |
384 |
|
cmp.w #$7100,d0 |
398 |
|
move.l $10.w,-(sp) ;Jump to MacOS exception handler |
399 |
|
rts |
400 |
|
|
401 |
< |
1$: |
422 |
< |
move.l a6,(sp) ;Save a6 |
401 |
> |
1$ move.l a6,(sp) ;Save a6 |
402 |
|
move.l usp,a6 ;Get user stack pointer |
403 |
|
|
404 |
|
move.l a6,-10(a6) ;Push USP (a7) |
453 |
|
cmp.w #$40d0,d0 ;move sr,(a0)? |
454 |
|
beq movefromsra0 |
455 |
|
cmp.w #$40d7,d0 ;move sr,(sp)? |
456 |
< |
beq movefromsrsp ;+++jl+++ |
456 |
> |
beq movefromsrsp |
457 |
|
|
458 |
|
cmp.w #$f327,d0 ;fsave -(sp)? |
459 |
|
beq fsavepush |
696 |
|
rte |
697 |
|
|
698 |
|
; fsave xxx(a5) +jl+ |
699 |
< |
fsavea5: move.l (sp),d0 ;Restore d0 |
699 |
> |
fsavea5 move.l (sp),d0 ;Restore d0 |
700 |
|
move.l a0,(sp) ;Save a0 |
701 |
|
move.l a5,a0 ;Get base register |
702 |
|
add.w ([6,sp],2),a0 ;Add offset to base register |
725 |
|
lea 16+4(sp),a1 ; destination address (in supervisor stack) |
726 |
|
bra 1$ |
727 |
|
|
728 |
< |
2$: move.w (a0)+,(a1)+ ; copy additional stack words back to supervisor stack |
729 |
< |
1$: dbf d0,2$ |
728 |
> |
2$ move.w (a0)+,(a1)+ ; copy additional stack words back to supervisor stack |
729 |
> |
1$ dbf d0,2$ |
730 |
|
|
731 |
|
move.l a0,usp ;Update USP |
732 |
|
movem.l (sp)+,a0/a1 ;Restore a0 and a1 |
868 |
|
beq.s movectcd0 |
869 |
|
cmp.w #$1003,d0 ;movec tc,d1? |
870 |
|
beq.s movectcd1 |
871 |
< |
cmp.w #$1000,d0 ;movec SFC,d1? |
871 |
> |
cmp.w #$1000,d0 ;movec sfc,d1? |
872 |
|
beq movecsfcd1 |
873 |
< |
cmp.w #$1001,d0 ;movec DFC,d1? |
873 |
> |
cmp.w #$1001,d0 ;movec dfc,d1? |
874 |
|
beq movecdfcd1 |
875 |
< |
cmp.w #$0806,d0 ;movec URP,d0? |
875 |
> |
cmp.w #$0806,d0 ;movec urp,d0? |
876 |
|
beq movecurpd0 |
877 |
< |
cmp.w #$0807,d0 ;movec SRP,d0? |
877 |
> |
cmp.w #$0807,d0 ;movec srp,d0? |
878 |
|
beq.s movecsrpd0 |
879 |
< |
cmp.w #$0004,d0 ;movec ITT0,d0 |
879 |
> |
cmp.w #$0004,d0 ;movec itt0,d0 |
880 |
|
beq.s movecitt0d0 |
881 |
< |
cmp.w #$0005,d0 ;movec ITT1,d0 |
881 |
> |
cmp.w #$0005,d0 ;movec itt1,d0 |
882 |
|
beq.s movecitt1d0 |
883 |
< |
cmp.w #$0006,d0 ;movec DTT0,d0 |
883 |
> |
cmp.w #$0006,d0 ;movec dtt0,d0 |
884 |
|
beq.s movecdtt0d0 |
885 |
< |
cmp.w #$0007,d0 ;movec DTT1,d0 |
885 |
> |
cmp.w #$0007,d0 ;movec dtt1,d0 |
886 |
|
beq.s movecdtt1d0 |
887 |
|
|
888 |
|
bra pv_unhandled |
929 |
|
addq.l #4,2(sp) |
930 |
|
rte |
931 |
|
|
932 |
< |
; movec SFC,d1 +jl+ |
933 |
< |
movecsfcd1: move.l (sp)+,d0 ;Restore d0 |
934 |
< |
moveq #0,d1 ;MMU is always off |
932 |
> |
; movec sfc,d1 +jl+ |
933 |
> |
movecsfcd1 move.l (sp)+,d0 ;Restore d0 |
934 |
> |
moveq #0,d1 |
935 |
|
addq.l #4,2(sp) |
936 |
|
rte |
937 |
|
|
938 |
< |
; movec DFC,d1 +jl+ |
939 |
< |
movecdfcd1: move.l (sp)+,d0 ;Restore d0 |
940 |
< |
moveq #0,d1 ;MMU is always off |
938 |
> |
; movec dfc,d1 +jl+ |
939 |
> |
movecdfcd1 move.l (sp)+,d0 ;Restore d0 |
940 |
> |
moveq #0,d1 |
941 |
|
addq.l #4,2(sp) |
942 |
|
rte |
943 |
|
|
944 |
< |
movecurpd0: ; movec URP,d0 +jl+ |
945 |
< |
movecsrpd0: ; movec SRP,d0 |
946 |
< |
movecitt0d0: ; movec ITT0,d0 |
947 |
< |
movecitt1d0: ; movec ITT1,d0 |
948 |
< |
movecdtt0d0: ; movec DTT0,d0 |
949 |
< |
movecdtt1d0: ; movec DTT1,d0 |
944 |
> |
movecurpd0 ; movec urp,d0 +jl+ |
945 |
> |
movecsrpd0 ; movec srp,d0 |
946 |
> |
movecitt0d0 ; movec itt0,d0 |
947 |
> |
movecitt1d0 ; movec itt1,d0 |
948 |
> |
movecdtt0d0 ; movec dtt0,d0 |
949 |
> |
movecdtt1d0 ; movec dtt1,d0 |
950 |
|
addq.l #4,sp |
951 |
|
moveq.l #0,d0 ;MMU is always off |
952 |
|
addq.l #4,2(sp) ;skip instruction |
963 |
|
beq.s movectocacr |
964 |
|
cmp.w #$1002,d0 ;movec d1,cacr? |
965 |
|
beq.s movectocacr |
966 |
< |
cmp.w #$1000,d0 ;movec d1,SFC? |
966 |
> |
cmp.w #$1000,d0 ;movec d1,sfc? |
967 |
|
beq.s movectoxfc |
968 |
< |
cmp.w #$1001,d0 ;movec d1,DFC? |
968 |
> |
cmp.w #$1001,d0 ;movec d1,dfc? |
969 |
|
beq.s movectoxfc |
970 |
|
|
971 |
|
bra pv_unhandled |
984 |
|
addq.l #4,2(sp) |
985 |
|
rte |
986 |
|
|
987 |
< |
; movec x,SFC |
988 |
< |
; movec x,DFC |
987 |
> |
; movec x,sfc |
988 |
> |
; movec x,dfc |
989 |
|
movectoxfc move.l (sp)+,d0 ;Ignore moves to SFC, DFC |
990 |
|
addq.l #4,2(sp) |
991 |
|
rte |
1001 |
|
rte |
1002 |
|
|
1003 |
|
; move usp,a1 +jl+ |
1004 |
< |
moveuspa1: move.l (sp)+,d0 |
1004 |
> |
moveuspa1 move.l (sp)+,d0 |
1005 |
|
move usp,a1 |
1006 |
|
addq.l #2,2(sp) |
1007 |
|
rte |
1008 |
|
|
1009 |
|
; move usp,a0 +jl+ |
1010 |
< |
moveuspa0: move.l (sp)+,d0 |
1010 |
> |
moveuspa0 move.l (sp)+,d0 |
1011 |
|
move usp,a0 |
1012 |
|
addq.l #2,2(sp) |
1013 |
|
rte |
1014 |
|
|
1015 |
|
; move a1,usp +jl+ |
1016 |
< |
moved1usp: move.l (sp)+,d0 |
1016 |
> |
moved1usp move.l (sp)+,d0 |
1017 |
|
move a1,usp |
1018 |
|
addq.l #2,2(sp) |
1019 |
|
rte |
1022 |
|
; Trigger NMI (Pop up debugger) |
1023 |
|
; |
1024 |
|
|
1025 |
< |
_AsmTriggerNMI: |
1047 |
< |
move.l d0,-(sp) ;Save d0 |
1025 |
> |
_AsmTriggerNMI move.l d0,-(sp) ;Save d0 |
1026 |
|
move.w #$007c,-(sp) ;Yes, fake NMI stack frame |
1027 |
|
pea 1$ |
1028 |
|
move.w _EmulatedSR,d0 |