diff --git a/sw/Makefile b/sw/Makefile index 85f9116..011f486 100644 --- a/sw/Makefile +++ b/sw/Makefile @@ -2,7 +2,7 @@ CC=cl65 CFLAGS=-t none LDFLAGS=-C link.ld -NAME=main +NAME=bootrom BIN=$(NAME).bin HEX=$(NAME).hex diff --git a/sw/boot.S b/sw/boot.S new file mode 100644 index 0000000..bd9645c --- /dev/null +++ b/sw/boot.S @@ -0,0 +1,13 @@ + .import _main + + .segment "VECTORS" + + .addr _init + .addr _init + .addr _init + + .code + +_init: jsr _main + +end: jmp end diff --git a/sw/link.ld b/sw/link.ld index f4ca7d7..489666d 100644 --- a/sw/link.ld +++ b/sw/link.ld @@ -1,10 +1,35 @@ MEMORY { - ROM: start=$8000, size=$8000, type=ro, define=yes, fill=yes, file=%O; + ZP: start = $0, size = $100, type = rw, define = yes; + RAM: start = $0200, size = $7D00, type = rw, define = yes; + ROM: start = $8000, size = $8000, fill = yes, fillval = $ff, file = %O; } -SEGMENTS -{ - CODE: load=ROM, type=ro; - VECTORS: load=ROM, type=ro, offset=$7ffa; +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + DATA: load = ROM, type = rw, define = yes, run = RAM; + BSS: load = RAM, type = bss, define = yes; + HEAP: load = RAM, type = bss, optional = yes; + STARTUP: load = ROM, type = ro; + ONCE: load = ROM, type = ro, optional = yes; + CODE: load = ROM, type = ro; + RODATA: load = ROM, type = ro; + VECTORS: load = ROM, type = ro, start = $FFFA; +} + +FEATURES { + CONDES: segment = STARTUP, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = STARTUP, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} + +SYMBOLS { + # Define the stack size for the application + __STACKSIZE__: value = $0200, type = weak; + __STACKSTART__: type = weak, value = $0800; # 2k stack } diff --git a/sw/main.S b/sw/main.S deleted file mode 100644 index 6a0ecb8..0000000 --- a/sw/main.S +++ /dev/null @@ -1,10 +0,0 @@ - .setcpu "6502" - .segment "VECTORS" - - .word loop - .word loop - .word loop - - .code -loop: lda #$12 - jmp loop diff --git a/sw/main.c b/sw/main.c new file mode 100644 index 0000000..499dad1 --- /dev/null +++ b/sw/main.c @@ -0,0 +1,4 @@ + +int main() { + return 1; +}