32x mostly works
[megadrive.git] / testpico / sega_gcc.s
index 10f5f62..efe0a00 100644 (file)
@@ -1,5 +1,5 @@
 exc_tab:\r
-    dc.l     0, 0x200, exc02, exc03, exc04, exc05, exc06, exc07\r
+    dc.l     0,   RST, exc02, exc03, exc04, exc05, exc06, exc07\r
     dc.l exc08, exc09, exc0a, exc0b, exc0c, exc0d, exc0e, exc0f\r
     dc.l exc10, exc11, exc12, exc13, exc14, exc15, exc16, exc17\r
     dc.l exc18, exc19, exc1a, exc1b, 0xff0100, exc1d, 0xff0140, exc1f\r
@@ -23,84 +23,11 @@ exc_tab:
     .ascii "                        "\r
     .ascii "JUE             "                        /* 1f0 */\r
 \r
-RST:\r
-    move.w  #0x2700, %sr\r
-\r
-    move.b (0xA10001), %d0\r
-    andi.b #0x0F, %d0\r
-    beq.s 0f\r
-    move.l  #0x53454741, (0xA14000) /* 'SEGA' */\r
-0:\r
-       tst.w   (0xc00004).l\r
-\r
-    moveq   #0, %d0\r
-    movea.l %d0, %a7\r
-    move    %a7, %usp\r
-\r
-    /* clear .bss */\r
-    lea     __bss_start, %a0\r
-    lea     __end, %a1\r
-0:\r
-    move.l  %d0, (%a0)+\r
-    cmp.l   %a1, %a0\r
-    blt.s   0b\r
-\r
-#    move.w  #0x2000, %sr\r
-    jsr     main\r
-0:\r
-    bra     0b\r
-\r
-#HBL:\r
-#VBL:\r
-#    rte\r
-\r
-pre_exception:\r
-    move.w  #0x2700, %sr\r
-    movem.l %d0-%d7/%a0-%a7,-(%sp)\r
-    move.l %sp, %d0\r
-    move.l %d0,-(%sp)\r
-    jsr exception\r
-0:\r
-    bra 0b\r
-\r
-.macro exc_stub num\r
-exc\num:\r
-    move.w #0x\num, -(%sp)\r
-    jmp pre_exception\r
-.endm\r
-\r
-exc_stub 02\r
-exc_stub 03\r
-exc_stub 04\r
-exc_stub 05\r
-exc_stub 06\r
-exc_stub 07\r
-exc_stub 08\r
-exc_stub 09\r
-exc_stub 0a\r
-exc_stub 0b\r
-exc_stub 0c\r
-exc_stub 0d\r
-exc_stub 0e\r
-exc_stub 0f\r
-exc_stub 10\r
-exc_stub 11\r
-exc_stub 12\r
-exc_stub 13\r
-exc_stub 14\r
-exc_stub 15\r
-exc_stub 16\r
-exc_stub 17\r
-exc_stub 18\r
-exc_stub 19\r
-exc_stub 1a\r
-exc_stub 1b\r
-HBL:\r
-exc_stub 1c\r
-exc_stub 1d\r
-VBL:\r
-exc_stub 1e\r
-exc_stub 1f\r
+# mystery landing area for reset with 32X on and RV=1\r
+# 2c8 - 304 in multiples of 4\r
+.rept 0x1c0/2\r
+    illegal\r
+.endr\r
 \r
     /* MARS data */\r
     .org 0x3c0\r
@@ -109,10 +36,10 @@ exc_stub 1f
     .long sh2_test   /* ROM src */\r
     .long 0          /* SDRAM dst */\r
     .long sh2_test_end-sh2_test /* length */\r
-    .long 0x06000244 /* master entry */\r
-    .long 0x06000248 /* slave entry */\r
+    .long 0x06000400 /* master entry */\r
+    .long 0x06000404 /* slave entry */\r
     .long 0x06000000 /* master VBR */\r
-    .long 0x06000124 /* slave VBR */\r
+    .long 0x06000200 /* slave VBR */\r
     /* Standard 32X startup code for MD side at 0x3F0 */\r
     .org 0x3f0\r
     .word 0x287C,0xFFFF,0xFFC0,0x23FC,0x0000,0x0000,0x00A1,0x5128\r
@@ -181,6 +108,87 @@ exc_stub 1f
     .word 0xFFC0,0x4CD6,0x7FF9,0x44FC,0x0000,0x6014,0x43F9,0x00A1\r
     .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
+0:\r
+    tst.w   (0xc00004).l\r
+\r
+    moveq   #0, %d0\r
+    movea.l %d0, %a7\r
+    move    %a7, %usp\r
+\r
+    /* clear .bss */\r
+    lea     __bss_start, %a0\r
+    lea     __end, %a1\r
+0:\r
+    move.l  %d0, (%a0)+\r
+    cmp.l   %a1, %a0\r
+    blt.s   0b\r
+\r
+#    move.w  #0x2000, %sr\r
+    jsr     main\r
+0:\r
+    bra     0b\r
+\r
+#HBL:\r
+#VBL:\r
+#    rte\r
+\r
+pre_exception:\r
+    move.w  #0x2700, %sr\r
+    movem.l %d0-%d7/%a0-%a7,-(%sp)\r
+    add.w   #2, 0x3e(%sp)\r
+    move.l  %sp, %d0\r
+    move.l  %d0,-(%sp)\r
+    jsr     exception\r
+0:\r
+    bra     0b\r
+\r
+.macro exc_stub num\r
+exc\num:\r
+    move.w #0x\num, -(%sp)\r
+    jmp pre_exception\r
+.endm\r
+\r
+exc_stub 02\r
+exc_stub 03\r
+exc_stub 04\r
+exc_stub 05\r
+exc_stub 06\r
+exc_stub 07\r
+exc_stub 08\r
+exc_stub 09\r
+exc_stub 0a\r
+exc_stub 0b\r
+exc_stub 0c\r
+exc_stub 0d\r
+exc_stub 0e\r
+exc_stub 0f\r
+\r
+exc_stub 10\r
+exc_stub 11\r
+exc_stub 12\r
+exc_stub 13\r
+exc_stub 14\r
+exc_stub 15\r
+exc_stub 16\r
+exc_stub 17\r
+exc_stub 18\r
+exc_stub 19\r
+exc_stub 1a\r
+exc_stub 1b\r
+HBL:\r
+exc_stub 1c\r
+exc_stub 1d\r
+VBL:\r
+exc_stub 1e\r
+exc_stub 1f\r
+\r
 exc_stub 20\r
 exc_stub 21\r
 exc_stub 22\r
@@ -214,8 +222,17 @@ exc_stub 3d
 exc_stub 3e\r
 exc_stub 3f\r
 \r
-.section .rodata\r
-.align 2\r
+.align 4\r
+\r
+# must avoid anything use 1070, 2070, 3070 after RV is set,\r
+# so let's place some data here\r
+.global z80_test\r
+.global z80_test_end\r
+z80_test:\r
+.incbin "z80_test.bin80"\r
+z80_test_end:\r
+\r
+.align 4\r
 \r
 .global sh2_test\r
 .global sh2_test_end\r
@@ -223,4 +240,14 @@ sh2_test:
 .incbin "sh2_test.binsh"\r
 sh2_test_end:\r
 \r
+.org 0x2070\r
+.long 0x1234567f\r
+\r
+.global font_base\r
+font_base:\r
+.incbin "font.bin"\r
+\r
+.org 0x3070\r
+.long 0x3456789f\r
+\r
 # vim:filetype=asmM68k:ts=4:sw=4:expandtab\r