Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akemin-dayo/38200da0c42f9aebe55bd521970c9361 to your computer and use it in GitHub Desktop.
Save akemin-dayo/38200da0c42f9aebe55bd521970c9361 to your computer and use it in GitHub Desktop.
Extremely barebones Mega Drive application that causes a 68000 memory address error exception and… does literally nothing else. (Yes, I wrote this solely just to help reproduce an emulator crash.)
; Mega Drive Memory Access Error Exception Tester
; Karen/あけみ (akemin_dayo)
; Extremely barebones Mega Drive application that causes a 68000 memory address error exception and… does literally nothing else.
; (Yes, I wrote this solely just to help reproduce an emulator crash.)
; Build instructions:
; asm68k /p MegaDriveMemoryAccessErrorExceptionTester.asm,MegaDriveMemoryAccessErrorExceptionTester.md
ROMstart:
; 68000 CPU vector table
dc.l 0x00FFE000 ; Initial stack pointer value
dc.l main ; Start of program
dc.l stub ; Bus error
dc.l stub ; Address error (4)
dc.l stub ; Illegal instruction
dc.l stub ; Division by zero
dc.l stub ; CHK exception
dc.l stub ; TRAPV exception (8)
dc.l stub ; Privilege violation
dc.l stub ; TRACE exception
dc.l stub ; Line-A emulator
dc.l stub ; Line-F emulator (12)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved) (16)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved) (20)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved) (24)
dc.l stub ; Spurious exception
dc.l stub ; IRQ level 1
dc.l stub ; IRQ level 2
dc.l stub ; IRQ level 3 (28)
dc.l stub ; IRQ level 4 (horizontal retrace interrupt)
dc.l stub ; IRQ level 5
dc.l stub ; IRQ level 6 (vertical retrace interrupt)
dc.l stub ; IRQ level 7 (32)
dc.l stub ; TRAP #00 exception
dc.l stub ; TRAP #01 exception
dc.l stub ; TRAP #02 exception
dc.l stub ; TRAP #03 exception (36)
dc.l stub ; TRAP #04 exception
dc.l stub ; TRAP #05 exception
dc.l stub ; TRAP #06 exception
dc.l stub ; TRAP #07 exception (40)
dc.l stub ; TRAP #08 exception
dc.l stub ; TRAP #09 exception
dc.l stub ; TRAP #10 exception
dc.l stub ; TRAP #11 exception (44)
dc.l stub ; TRAP #12 exception
dc.l stub ; TRAP #13 exception
dc.l stub ; TRAP #14 exception
dc.l stub ; TRAP #15 exception (48)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
dc.l stub ; Unused (reserved)
; Mega Drive ROM header
dc.b "SEGA MEGA DRIVE " ; [0x100, 16 bytes] System type
dc.b "(C)akemin_dayo " ; [0x110, 16 bytes] Copyright
dc.b "Mega Drive Memory Access Error Exception Tester " ; [0x120, 48 bytes] Domestic title
dc.b "Mega Drive Memory Access Error Exception Tester " ; [0x150, 48 bytes] Overseas title
dc.b "GM AKM-7373-00" ; [0x180, 14 bytes] Serial number
dc.w 0x7373 ; [0x18E, 2 bytes] Checksum
dc.b "J " ; [0x190, 16 bytes] I/O support
dc.l ROMstart, ROMend - 1 ; [0x1A0, 8 bytes] ROM address range
dc.l 0x00FF0000, 0x00FFFFFF ; [0x1A8, 8 bytes] RAM address range
dc.b " ", 0x00, 0x00 ; [0x1B0, 4 bytes] SRAM/EEPROM type
dc.l 0x00000000, 0x00000000 ; [0x1B4, 8 bytes] SRAM/EEPROM address range
dc.b " " ; [0x1BC, 12 bytes] Modem support
dc.b " " ; [0x1C8, 40 bytes] Memo/Notes (Unused)
dc.b "JUE" ; [0x1F0, 3 bytes] Region
dc.b " " ; [0x1F3, 13 bytes] Unused
main:
; The 68000 CPU can only access words (or long words) at even memory addresses.
; So, to purposefully cause a memory address error exception to occur, we can just simply attempt to read a word from an odd memory address.
move.w 0x00000001, d0
stub:
; Stub out all interrupts.
rte
ROMend:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment