diff --git a/libsrc/apple2/crt0.s b/libsrc/apple2/crt0.s index d51c282a2..b1f801521 100644 --- a/libsrc/apple2/crt0.s +++ b/libsrc/apple2/crt0.s @@ -7,11 +7,20 @@ .export _exit .import initlib, donelib .import zerobss, push0 + .import __CODE_LOAD__, __BSS_LOAD__ ; Linker generated .import _main .include "zeropage.inc" .include "apple2.inc" +; ------------------------------------------------------------------------ +; The executable header + +.segment "EXEHDR" + + .word __CODE_LOAD__ ; Start address + .word __BSS_LOAD__ - __CODE_LOAD__ ; Size + ; ------------------------------------------------------------------------ ; Actual code diff --git a/src/ld65/cfg/apple2.cfg b/src/ld65/cfg/apple2.cfg index c0bf96435..89ab2ef54 100644 --- a/src/ld65/cfg/apple2.cfg +++ b/src/ld65/cfg/apple2.cfg @@ -1,9 +1,11 @@ MEMORY { ZP: start = $00, size = $1A, type = rw, define = yes; + HEADER: start = $0000, size = $4, file = %O; RAM: start = $800, size = $8E00, file = %O; } SEGMENTS { - CODE: load = RAM, type = ro; + EXEHDR: load = HEADER, type = ro; + CODE: load = RAM, type = ro, define = yes; RODATA: load = RAM, type = ro; DATA: load = RAM, type = rw; BSS: load = RAM, type = bss, define = yes;