Last active
April 19, 2017 06:37
-
-
Save alangarf/f1eb78649316e6f3ac7698e1e1facb2c to your computer and use it in GitHub Desktop.
m68k exception nuts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Silly issue with m68k never going into exception functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MEMORY | |
{ | |
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x10000 | |
RAML (xrw) : ORIGIN = 0x00020000, LENGTH = 0x10000 | |
RAMH (xrw) : ORIGIN = 0x00030000, LENGTH = 0x10000 | |
} | |
stack_size = 1024; | |
_stack_start = ORIGIN(RAML)+LENGTH(RAML)-0x10; | |
_stack_end = _stack_start - stack_size; | |
SECTIONS { | |
.vectors 0x00 : | |
{ | |
. = ALIGN(4); | |
KEEP(*(.vectors)) | |
. = ALIGN(4); | |
} > ROM | |
.text 0x400 : { | |
. = ALIGN(4); | |
*(.text) | |
*(.rodata) | |
. = ALIGN(4); | |
} > ROM | |
.data : { *(.data) } > RAML | |
.bss : { *(.bss) *(COMMON) } > RAML | |
} | |
OUTPUT_ARCH(m68k:68000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
M68K=m68k-linux-gnu | |
AS=$(M68K)-as | |
LD=$(M68K)-ld | |
COPY=$(M68K)-objcopy | |
DUMP=$(M68K)-objdump | |
CPU=-m68000 | |
ASFLAGS=$(CPU) --warn --fatal-warnings | |
LDFLAGS=-T m68k.ld | |
EEPROM=AT28C256 | |
PREFIX=m68k- | |
FMT=binary | |
SRCS=test.s | |
OBJS=$(SRCS:.s=.o) | |
MAIN=test | |
.PHONY: dump clean | |
all: $(MAIN) | |
.s.o: | |
$(AS) $(ASFLAGS) -o $@ $< | |
$(MAIN): $(OBJS) | |
$(LD) $(LDFLAGS) -o $(MAIN).a $(OBJS) | |
$(COPY) -O $(FMT) $(MAIN).a $(PREFIX)$(MAIN).bin | |
$(COPY) -b 0 -i 2 --interleave-width=1 -O $(FMT) $(MAIN).a $(PREFIX)$(MAIN)-even.bin | |
$(COPY) -b 1 -i 2 --interleave-width=1 -O $(FMT) $(MAIN).a $(PREFIX)$(MAIN)-odd.bin | |
clean: | |
rm -f *.o $(PREFIX)$(MAIN)-even.bin $(PREFIX)$(MAIN)-odd.bin $(PREFIX)$(MAIN).bin $(MAIN).a | |
dump: $(MAIN) | |
$(DUMP) $(CPU) -x -D $(MAIN).a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Memory Map | |
* -------------- | |
* 0x00000-0x0FFFF System ROM | |
* 0x10000-0x1FFFF System ROM alias | |
* 0X20000-0x2FFFF RAM BANK 1 | |
* 0x30000-0x3FFFF RAM BANK 2 | |
* 0x40000-0x40001 UARTS | |
* 0x50000-0x500xx CALENDAR INPUT | |
* 0x60000-0x600xx CALENDAR/LED OUTPUT | |
* 0x70000-0x700xx DIP SWITCH INPUT | |
* | |
*/ | |
.section .vectors, "ax" | |
.title "Init vectors" | |
.long _stack_start | |
.long .main | |
.long .error | bus error | |
.long .error | address error | |
.long .error | illegal instruction | |
.long .error | divide by zero | |
.long .error | CHK instruction | |
.long .error | TRAPV instruction | |
.long .error | privilege violation | |
.long .error | trace | |
.long .error | line 1010 emulator | |
.long .error | line 1111 emulator | |
.rept 0x03 | |
.long 0x00000000 | reserved | |
.endr | |
.long .error | uninitialised interrupt | |
.rept 0x08 | |
.long 0x00000000 | reserved | |
.endr | |
.long .error | spurious interrupt | |
.long .error | int 1 | |
.long .error | int 2 | |
.long .error | int 3 | |
.long .error | int 4 | |
.long .error | int 5 | |
.long .error | int 6 | |
.long .error | int 7 | |
.long .error | trap #0 | |
.long .error | trap #1 | |
.long .error | trap #2 | |
.long .error | trap #3 | |
.long .error | trap #4 | |
.long .error | trap #5 | |
.long .error | trap #6 | |
.long .error | trap #7 | |
.long .error | trap #8 | |
.long .error | trap #9 | |
.long .error | trap #10 | |
.long .error | trap #11 | |
.long .error | trap #12 | |
.long .error | trap #13 | |
.long .error | trap #14 | |
.long .error | trap #15 | |
.rept 0x10 | |
.long 0x00000000 | reserved | |
.endr | |
|.rept 0xC0 | |
|.long .error | user interrupts | |
|.endr | |
.section .text | |
.title "Program" | |
.main: | |
lea _stack_start, %sp | |
move.b #0x0f, 0x60000 | turn on LED | |
.word 0x4afc | illegal instruction so we should get exception | |
.align 2 | |
.die: jmp .die | useless loop | |
************************************************************************* | |
* | |
* Exception functions | |
* | |
.error: | |
move.b #0x0e, 0x60000 | turn off LED | |
rte |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment