testpico: show that vres clear is separate
[megadrive.git] / testpico / sega_gcc.s
index d4fdc58..4abb418 100644 (file)
@@ -16,16 +16,19 @@ exc_tab:
     .ascii "J               "\r
     .long  0x000000,0x3fffff\r
     .long  0xff0000,0xffffff\r
-    .ascii "RA"; .byte 0xf8,0x20                     /* 1b0 */\r
-    .long  0x200001,0x20ffff                         /* 1b4 */\r
-    .ascii "    "                                    /* 1bc */\r
-    .ascii "                        "                /* 1c0 */\r
-    .ascii "                        "\r
-    .ascii "JUE             "                        /* 1f0 */\r
+    .ascii "RA"; .byte 0xf8,0x20                      /* 1b0 */\r
+    .long  0x200001,0x20ffff                          /* 1b4 */\r
+    .ascii "    "                                     /* 1bc */\r
+    .ascii "        "                                 /* 1c0 */\r
+    .ascii "src: https://github.com/notaz/megadrive/" /* 1c8 */\r
+    .ascii "JUE             "                         /* 1f0 */\r
+\r
+# 32X reset vector (880200)\r
+    bra     RST32X\r
 \r
 # mystery landing area for reset with 32X on and RV=1\r
 # 2c8 - 304 in multiples of 4\r
-.rept 0x1c0/2\r
+.rept 0x1bc/2\r
     illegal\r
 .endr\r
 \r
@@ -109,20 +112,22 @@ exc_tab:
     .word 0x5100,0x3340,0x0006,0x303C,0x8000,0x6004,0x44FC,0x0001\r
 \r
 RST:\r
-    move.w  #0x2600, %sr\r
-\r
-    move.b (0xA10001), %d0\r
-    andi.b #0x0F, %d0\r
-    beq.s 0f\r
-    move.l  #0x53454741, (0xA14000) /* 'SEGA' */\r
+    andi.b  #0x0F, (0xA10001)       /* 24 */\r
+    bne.s   0f                      /* 10 */\r
+    move.w  #0x8104, (0xc00004)\r
+    bra     1f\r
 0:\r
-    tst.w   (0xc00004).l\r
+    move.l  #0x53454741, (0xA14000) /* 28 'SEGA' */\r
+1:\r
+    move.w  (0xc00008), %d0         /* 16 */\r
+    move.w  %d0, -(%sp)\r
+    subq.l  #2, %sp\r
+    move    %sp, %usp\r
 \r
-    moveq   #0, %d0\r
-    movea.l %d0, %a7\r
-    move    %a7, %usp\r
+    move.w  #0x2600, %sr\r
 \r
     /* clear .bss */\r
+    moveq.l #0, %d0\r
     lea     __bss_start, %a0\r
     lea     __end, %a1\r
 0:\r
@@ -139,12 +144,29 @@ RST:
 #VBL:\r
 #    rte\r
 \r
+RST32X:\r
+    lea     ram_rv_switch, %a0\r
+    movea.l #0xff0100, %a1\r
+    lea     ram_rv_switch_end, %a2\r
+0:\r
+    move.l  (%a0)+, (%a1)+\r
+    cmp.l   %a2, %a0\r
+    blt.s   0b\r
+    jmp     (0xff0100).l\r
+\r
+ram_rv_switch:\r
+    move.l  (0x880004).l, %a0\r
+    bset    #0, (0xa15107).l  /* RV=1 */\r
+    nop                       /* just in case */\r
+    jmp     (%a0)\r
+ram_rv_switch_end:\r
+\r
 pre_exception:\r
     move.w  #0x2700, %sr\r
     movem.l %d0-%d7/%a0-%a7,-(%sp)\r
-    add.w   #2, 0x3e(%sp)\r
+    add.w   #2, 0x3e(%sp)   /* ecxnum */\r
     move.l  %sp, %d0\r
-    move.l  %d0,-(%sp)  /* arg0 */\r
+    move.l  %d0,-(%sp)      /* arg0 */\r
     jsr     exception\r
 0:\r
     bra     0b\r
@@ -152,7 +174,7 @@ pre_exception:
 .macro exc_stub num\r
 exc\num:\r
     move.w #0x\num, -(%sp)\r
-    jmp pre_exception\r
+    bra pre_exception\r
 .endm\r
 \r
 exc_stub 02\r