Hi,
I'm trying to get a very small sample up and running - not even Hello World, not even initialising the VDP or Z80, just move one register to another - to make sure my toolchain is up to scratch and that my debugger of choice (MESS) is working correctly, but after a few days of trying I haven't had much luck.
Here's my code, it's a mash of different samples and tutorials from all over the net, trimmed down to something which I can start off with:
RomStart:
; ******************************************************************
; Sega Megadrive ROM header
; ******************************************************************
dc.l 0x00FFE000 ; Initial stack pointer value
dc.l EntryPoint ; Start of program
dc.l Exception ; Bus error
dc.l Exception ; Address error
dc.l Exception ; Illegal instruction
dc.l Exception ; Division by zero
dc.l Exception ; CHK exception
dc.l Exception ; TRAPV exception
dc.l Exception ; Privilege violation
dc.l Exception ; TRACE exception
dc.l Exception ; Line-A emulator
dc.l Exception ; Line-F emulator
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Spurious exception
dc.l Exception ; IRQ level 1
dc.l Exception ; IRQ level 2
dc.l Exception ; IRQ level 3
dc.l HBlankInterrupt ; IRQ level 4 (horizontal retrace interrupt)
dc.l Exception ; IRQ level 5
dc.l VBlankInterrupt ; IRQ level 6 (vertical retrace interrupt)
dc.l Exception ; IRQ level 7
dc.l Exception ; TRAP #00 exception
dc.l Exception ; TRAP #01 exception
dc.l Exception ; TRAP #02 exception
dc.l Exception ; TRAP #03 exception
dc.l Exception ; TRAP #04 exception
dc.l Exception ; TRAP #05 exception
dc.l Exception ; TRAP #06 exception
dc.l Exception ; TRAP #07 exception
dc.l Exception ; TRAP #08 exception
dc.l Exception ; TRAP #09 exception
dc.l Exception ; TRAP #10 exception
dc.l Exception ; TRAP #11 exception
dc.l Exception ; TRAP #12 exception
dc.l Exception ; TRAP #13 exception
dc.l Exception ; TRAP #14 exception
dc.l Exception ; TRAP #15 exception
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.b "SEGA GENESIS "
dc.b "(C)SEGA 1992.SEP"
dc.b "YOUR GAME HERE "
dc.b "YOUR GAME HERE "
dc.b "GM XXXXXXXX-XX"
dc.w 0
dc.b "J "
dc.l RomStart
dc.l RomEnd-1
dc.l $FF0000
dc.l $FFFFFF
dc.b " "
dc.b " "
dc.b " "
dc.b " "
dc.b " "
dc.b "JUE "
; ******************************************************************
; Entry Point
; ******************************************************************
EntryPoint:
move.l d0, d1 ; Do something
bra EntryPoint ; Do it again
; ******************************************************************
; Exception handler
; ******************************************************************
Exception:
bra Exception ; Just Loop
; ******************************************************************
; Sync interrupts
; ******************************************************************
HBlankInterrupt:
rts ; Do nothing
VBlankInterrupt:
rts ; Do nothing
RomEnd:
END
I'm assembling and preparing the BIN using:
C:\>asm68k.exe test2.asm,test2.bin
SN 68k version 2.53
Assembly completed.
0 error(s) from 88 lines in 0.0 seconds
C:\>rompad.exe test2.bin 255 0
Lightning's ROM Padder
C:\>fixheadr.exe test2.bin
Reported Size: 20202020 Reported Checksum: 2047
Size applied: 3FF Checksum Applied: 1C90
and all seems well. ASM68K is my assembler of choice since SNASM68K doesn't run on Windows 7 64 bit. The other two tools are from the Sonic disassembly dump, which included everything needed to assemble, pad and fix the header.
When I open the BIN using MESS and begin debugging, I see some invalid opcodes in the disassembly, and the program will not run:
![[IMG]](https://web.archive.org/web/2im_/http://i41.tinypic.com/10h59pd.png)
The disassembly doesn't seem to match any of the code I've written, although that may be because I'm just starting out and don't really know what I'm looking for yet.
I'm not sure if it's my code, the build process or the debugger which is at fault, but loading up a Sonic ROM in MESS runs and shows correct debug info.
Any help appreciated!
I'm trying to get a very small sample up and running - not even Hello World, not even initialising the VDP or Z80, just move one register to another - to make sure my toolchain is up to scratch and that my debugger of choice (MESS) is working correctly, but after a few days of trying I haven't had much luck.
Here's my code, it's a mash of different samples and tutorials from all over the net, trimmed down to something which I can start off with:
RomStart:
; ******************************************************************
; Sega Megadrive ROM header
; ******************************************************************
dc.l 0x00FFE000 ; Initial stack pointer value
dc.l EntryPoint ; Start of program
dc.l Exception ; Bus error
dc.l Exception ; Address error
dc.l Exception ; Illegal instruction
dc.l Exception ; Division by zero
dc.l Exception ; CHK exception
dc.l Exception ; TRAPV exception
dc.l Exception ; Privilege violation
dc.l Exception ; TRACE exception
dc.l Exception ; Line-A emulator
dc.l Exception ; Line-F emulator
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Spurious exception
dc.l Exception ; IRQ level 1
dc.l Exception ; IRQ level 2
dc.l Exception ; IRQ level 3
dc.l HBlankInterrupt ; IRQ level 4 (horizontal retrace interrupt)
dc.l Exception ; IRQ level 5
dc.l VBlankInterrupt ; IRQ level 6 (vertical retrace interrupt)
dc.l Exception ; IRQ level 7
dc.l Exception ; TRAP #00 exception
dc.l Exception ; TRAP #01 exception
dc.l Exception ; TRAP #02 exception
dc.l Exception ; TRAP #03 exception
dc.l Exception ; TRAP #04 exception
dc.l Exception ; TRAP #05 exception
dc.l Exception ; TRAP #06 exception
dc.l Exception ; TRAP #07 exception
dc.l Exception ; TRAP #08 exception
dc.l Exception ; TRAP #09 exception
dc.l Exception ; TRAP #10 exception
dc.l Exception ; TRAP #11 exception
dc.l Exception ; TRAP #12 exception
dc.l Exception ; TRAP #13 exception
dc.l Exception ; TRAP #14 exception
dc.l Exception ; TRAP #15 exception
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.l Exception ; Unused (reserved)
dc.b "SEGA GENESIS "
dc.b "(C)SEGA 1992.SEP"
dc.b "YOUR GAME HERE "
dc.b "YOUR GAME HERE "
dc.b "GM XXXXXXXX-XX"
dc.w 0
dc.b "J "
dc.l RomStart
dc.l RomEnd-1
dc.l $FF0000
dc.l $FFFFFF
dc.b " "
dc.b " "
dc.b " "
dc.b " "
dc.b " "
dc.b "JUE "
; ******************************************************************
; Entry Point
; ******************************************************************
EntryPoint:
move.l d0, d1 ; Do something
bra EntryPoint ; Do it again
; ******************************************************************
; Exception handler
; ******************************************************************
Exception:
bra Exception ; Just Loop
; ******************************************************************
; Sync interrupts
; ******************************************************************
HBlankInterrupt:
rts ; Do nothing
VBlankInterrupt:
rts ; Do nothing
RomEnd:
END
I'm assembling and preparing the BIN using:
C:\>asm68k.exe test2.asm,test2.bin
SN 68k version 2.53
Assembly completed.
0 error(s) from 88 lines in 0.0 seconds
C:\>rompad.exe test2.bin 255 0
Lightning's ROM Padder
C:\>fixheadr.exe test2.bin
Reported Size: 20202020 Reported Checksum: 2047
Size applied: 3FF Checksum Applied: 1C90
and all seems well. ASM68K is my assembler of choice since SNASM68K doesn't run on Windows 7 64 bit. The other two tools are from the Sonic disassembly dump, which included everything needed to assemble, pad and fix the header.
When I open the BIN using MESS and begin debugging, I see some invalid opcodes in the disassembly, and the program will not run:
![[IMG]](https://web.archive.org/web/2im_/http://i41.tinypic.com/10h59pd.png)
The disassembly doesn't seem to match any of the code I've written, although that may be because I'm just starting out and don't really know what I'm looking for yet.
I'm not sure if it's my code, the build process or the debugger which is at fault, but loading up a Sonic ROM in MESS runs and shows correct debug info.
Any help appreciated!
![[IMG]](https://web.archive.org/web/2im_/http://i41.tinypic.com/or19jr.png)
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/UtoGZ.png)
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/IZK8R.png)
![[IMG]](https://web.archive.org/web/2im_/http://i.imgur.com/IVz3m.png)
![[IMG]](https://web.archive.org/web/2im_/https://lh4.googleusercontent.com/-It9pKI1sbV8/S5-w1X6rUWI/AAAAAAAACKs/bsUJ9pXWLv0/s800/TV2010031513061000.jpg)
![[IMG]](https://web.archive.org/web/2im_/https://lh5.googleusercontent.com/-CCDrTKA7p54/TcvUoxWib4I/AAAAAAAADg8/vybpV4ch3vE/s800/stop_version3.jpg)
