FEATURES {
STARTADDRESS: default = $0803;
}
-SYMBOLS {
- __LOADADDR__: type = weak, value = __CODE_RUN__;
- __LOADSIZE__: type = weak, value = __BSS_RUN__ - __CODE_RUN__;
-}
MEMORY {
- ZP: start = $0080, size = $001A, define = yes;
- HEADER: file = %O, start = $0000, size = $0004;
- MAIN: file = %O, start = %S, size = $C000 - %S;
+ ZP: file = "", start = $0000, size = $00FF;
+ HEADER: file = %O, start = %S - 4, size = $0004;
+ MAIN: file = %O, define = yes, start = %S, size = $C000 - %S;
+ BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
EXEHDR: load = HEADER, type = ro, optional = yes;
- CODE: load = MAIN, type = rw, optional = yes, define = yes;
+ CODE: load = MAIN, type = rw, optional = yes;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
- BSS: load = MAIN, type = bss, optional = yes, define = yes;
+ BSS: load = BSS, type = bss, optional = yes, define = yes;
}
}
SYMBOLS {
__EXEHDR__: type = import;
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
__HIMEM__: type = weak, value = $9600; # Presumed RAM end
__LCADDR__: type = weak, value = $D400; # Behind quit code
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
- __STACKSIZE__: type = weak, value = $0800; # 2k stack
__OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay
- __LOADADDR__: type = weak, value = __STARTUP_RUN__;
- __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ +
- __MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
- ZP: define = yes, start = $0080, size = $001A;
- HEADER: file = %O, start = $0000, size = $0004;
- MAIN: file = %O, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __STACKSIZE__ - __OVERLAYSIZE__ - %S;
- MOVE: file = %O, define = yes, start = $0000, size = $FFFF;
- LC: define = yes, start = __LCADDR__, size = __LCSIZE__;
+ ZP: file = "", define = yes, start = $0080, size = $001A;
+ HEADER: file = %O, start = %S - 4, size = $0004;
+ MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __OVERLAYSIZE__ - %S;
+ BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
+ LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__;
OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__;
OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__;
OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__;
}
SEGMENTS {
- ZEROPAGE: load = ZP, type = zp;
- EXEHDR: load = HEADER, type = ro;
- STARTUP: load = MAIN, type = ro, define = yes;
- LOWCODE: load = MAIN, type = ro, optional = yes;
- CODE: load = MAIN, type = ro;
- RODATA: load = MAIN, type = ro;
- DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, define = yes;
- BSS: load = MAIN, type = bss, define = yes;
- ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes;
- LC: load = MOVE, run = LC, type = ro, optional = yes;
- OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
- OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes;
- OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes;
- OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes;
- OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes;
- OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes;
- OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes;
- OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes;
- OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes;
+ ZEROPAGE: load = ZP, type = zp;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = MAIN, type = ro, define = yes;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw;
+ ONCE: load = MAIN, type = ro, define = yes;
+ LC: load = MAIN, run = LC, type = ro, optional = yes;
+ BSS: load = BSS, type = bss, define = yes;
+ OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
+ OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes;
+ OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes;
+ OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes;
+ OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes;
+ OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes;
+ OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes;
+ OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes;
+ OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes;
}
FEATURES {
CONDES: type = constructor,
# Configuration for ProDOS 8 system programs (without the header)
SYMBOLS {
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
__LCADDR__: type = weak, value = $D400; # Behind quit code
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
- __STACKSIZE__: type = weak, value = $0800; # 2k stack
- __LOADADDR__: type = weak, value = __STARTUP_RUN__;
- __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ +
- __MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
- ZP: define = yes, start = $0080, size = $001A;
- MAIN: file = %O, start = $2000, size = $9F00 - __STACKSIZE__;
- MOVE: file = %O, define = yes, start = $0000, size = $FFFF;
- LC: define = yes, start = __LCADDR__, size = __LCSIZE__;
+ ZP: file = "", define = yes, start = $0080, size = $001A;
+ MAIN: file = %O, start = $2000, size = $BF00 - $2000;
+ BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__;
+ LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
}
SEGMENTS {
- ZEROPAGE: load = ZP, type = zp;
- STARTUP: load = MAIN, type = ro, define = yes;
- LOWCODE: load = MAIN, type = ro, optional = yes;
- CODE: load = MAIN, type = ro;
- RODATA: load = MAIN, type = ro;
- DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, define = yes;
- BSS: load = MAIN, type = bss, define = yes;
- ONCE: load = MOVE, run = RAM, type = ro, define = yes, optional = yes;
- LC: load = MOVE, run = LC, type = ro, optional = yes;
+ ZEROPAGE: load = ZP, type = zp;
+ STARTUP: load = MAIN, type = ro;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw;
+ ONCE: load = MAIN, type = ro, define = yes;
+ LC: load = MAIN, run = LC, type = ro, optional = yes;
+ BSS: load = BSS, type = bss, define = yes;
}
FEATURES {
CONDES: type = constructor,
}
SYMBOLS {
__EXEHDR__: type = import;
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
__HIMEM__: type = weak, value = $9600; # Presumed RAM end
__LCADDR__: type = weak, value = $D400; # Behind quit code
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
- __STACKSIZE__: type = weak, value = $0800; # 2k stack
- __LOADADDR__: type = weak, value = __STARTUP_RUN__;
- __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ +
- __MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
- ZP: define = yes, start = $0080, size = $001A;
- HEADER: file = %O, start = $0000, size = $0004;
- MAIN: file = %O, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S;
- MOVE: file = %O, define = yes, start = $0000, size = $FFFF;
- LC: define = yes, start = __LCADDR__, size = __LCSIZE__;
+ ZP: file = "", define = yes, start = $0080, size = $001A;
+ HEADER: file = %O, start = %S - 4, size = $0004;
+ MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S;
+ BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
+ LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
}
SEGMENTS {
- ZEROPAGE: load = ZP, type = zp;
- EXEHDR: load = HEADER, type = ro;
- STARTUP: load = MAIN, type = ro, define = yes;
- LOWCODE: load = MAIN, type = ro, optional = yes;
- CODE: load = MAIN, type = ro;
- RODATA: load = MAIN, type = ro;
- DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, define = yes;
- BSS: load = MAIN, type = bss, define = yes;
- ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes;
- LC: load = MOVE, run = LC, type = ro, optional = yes;
+ ZEROPAGE: load = ZP, type = zp;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = MAIN, type = ro;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw;
+ ONCE: load = MAIN, type = ro, define = yes;
+ LC: load = MAIN, run = LC, type = ro, optional = yes;
+ BSS: load = BSS, type = bss, define = yes;
}
FEATURES {
CONDES: type = constructor,
FEATURES {
STARTADDRESS: default = $0803;
}
-SYMBOLS {
- __LOADADDR__: type = weak, value = __CODE_RUN__;
- __LOADSIZE__: type = weak, value = __BSS_RUN__ - __CODE_RUN__;
-}
MEMORY {
- HEADER: file = %O, start = $0000, size = $0004;
- MAIN: file = %O, start = %S, size = $C000 - %S;
+ ZP: file = "", start = $0000, size = $00FF;
+ HEADER: file = %O, start = %S - 4, size = $0004;
+ MAIN: file = %O, define = yes, start = %S, size = $C000 - %S;
+ BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__;
}
SEGMENTS {
- EXEHDR: load = HEADER, type = ro, optional = yes;
- CODE: load = MAIN, type = rw, optional = yes, define = yes;
- RODATA: load = MAIN, type = ro, optional = yes;
- DATA: load = MAIN, type = rw, optional = yes;
- BSS: load = MAIN, type = bss, optional = yes, define = yes;
+ ZEROPAGE: load = ZP, type = zp, optional = yes;
+ EXEHDR: load = HEADER, type = ro, optional = yes;
+ CODE: load = MAIN, type = rw, optional = yes;
+ RODATA: load = MAIN, type = ro, optional = yes;
+ DATA: load = MAIN, type = rw, optional = yes;
+ BSS: load = BSS, type = bss, optional = yes, define = yes;
}
}
SYMBOLS {
__EXEHDR__: type = import;
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
__HIMEM__: type = weak, value = $9600; # Presumed RAM end
__LCADDR__: type = weak, value = $D400; # Behind quit code
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
- __STACKSIZE__: type = weak, value = $0800; # 2k stack
__OVERLAYSIZE__: type = weak, value = $1000; # 4k overlay
- __LOADADDR__: type = weak, value = __STARTUP_RUN__;
- __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ +
- __MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
- ZP: define = yes, start = $0080, size = $001A;
- HEADER: file = %O, start = $0000, size = $0004;
- MAIN: file = %O, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __STACKSIZE__ - __OVERLAYSIZE__ - %S;
- MOVE: file = %O, define = yes, start = $0000, size = $FFFF;
- LC: define = yes, start = __LCADDR__, size = __LCSIZE__;
+ ZP: file = "", define = yes, start = $0080, size = $001A;
+ HEADER: file = %O, start = %S - 4, size = $0004;
+ MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __OVERLAYSIZE__ - %S;
+ BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
+ LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
OVL1: file = "%O.1", start = %S, size = __OVERLAYSIZE__;
OVL2: file = "%O.2", start = %S, size = __OVERLAYSIZE__;
OVL3: file = "%O.3", start = %S, size = __OVERLAYSIZE__;
OVL9: file = "%O.9", start = %S, size = __OVERLAYSIZE__;
}
SEGMENTS {
- ZEROPAGE: load = ZP, type = zp;
- EXEHDR: load = HEADER, type = ro;
- STARTUP: load = MAIN, type = ro, define = yes;
- LOWCODE: load = MAIN, type = ro, optional = yes;
- CODE: load = MAIN, type = ro;
- RODATA: load = MAIN, type = ro;
- DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, define = yes;
- BSS: load = MAIN, type = bss, define = yes;
- ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes;
- LC: load = MOVE, run = LC, type = ro, optional = yes;
- OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
- OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes;
- OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes;
- OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes;
- OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes;
- OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes;
- OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes;
- OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes;
- OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes;
+ ZEROPAGE: load = ZP, type = zp;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = MAIN, type = ro, define = yes;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw;
+ ONCE: load = MAIN, type = ro, define = yes;
+ LC: load = MAIN, run = LC, type = ro, optional = yes;
+ BSS: load = BSS, type = bss, define = yes;
+ OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
+ OVERLAY2: load = OVL2, type = ro, define = yes, optional = yes;
+ OVERLAY3: load = OVL3, type = ro, define = yes, optional = yes;
+ OVERLAY4: load = OVL4, type = ro, define = yes, optional = yes;
+ OVERLAY5: load = OVL5, type = ro, define = yes, optional = yes;
+ OVERLAY6: load = OVL6, type = ro, define = yes, optional = yes;
+ OVERLAY7: load = OVL7, type = ro, define = yes, optional = yes;
+ OVERLAY8: load = OVL8, type = ro, define = yes, optional = yes;
+ OVERLAY9: load = OVL9, type = ro, define = yes, optional = yes;
}
FEATURES {
CONDES: type = constructor,
# Configuration for ProDOS 8 system programs (without the header)
SYMBOLS {
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
__LCADDR__: type = weak, value = $D400; # Behind quit code
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
- __STACKSIZE__: type = weak, value = $0800; # 2k stack
- __LOADADDR__: type = weak, value = __STARTUP_RUN__;
- __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ +
- __MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
- ZP: define = yes, start = $0080, size = $001A;
- MAIN: file = %O, start = $2000, size = $9F00 - __STACKSIZE__;
- MOVE: file = %O, define = yes, start = $0000, size = $FFFF;
- LC: define = yes, start = __LCADDR__, size = __LCSIZE__;
+ ZP: file = "", define = yes, start = $0080, size = $001A;
+ MAIN: file = %O, start = $2000, size = $BF00 - $2000;
+ BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__;
+ LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
}
SEGMENTS {
- ZEROPAGE: load = ZP, type = zp;
- STARTUP: load = MAIN, type = ro, define = yes;
- LOWCODE: load = MAIN, type = ro, optional = yes;
- CODE: load = MAIN, type = ro;
- RODATA: load = MAIN, type = ro;
- DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, define = yes;
- BSS: load = MAIN, type = bss, define = yes;
- ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes;
- LC: load = MOVE, run = LC, type = ro, optional = yes;
+ ZEROPAGE: load = ZP, type = zp;
+ STARTUP: load = MAIN, type = ro;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw;
+ ONCE: load = MAIN, type = ro, define = yes;
+ LC: load = MAIN, run = LC, type = ro, optional = yes;
+ BSS: load = BSS, type = bss, define = yes;
}
FEATURES {
CONDES: type = constructor,
}
SYMBOLS {
__EXEHDR__: type = import;
+ __STACKSIZE__: type = weak, value = $0800; # 2k stack
__HIMEM__: type = weak, value = $9600; # Presumed RAM end
__LCADDR__: type = weak, value = $D400; # Behind quit code
__LCSIZE__: type = weak, value = $0C00; # Rest of bank two
- __STACKSIZE__: type = weak, value = $0800; # 2k stack
- __LOADADDR__: type = weak, value = __STARTUP_RUN__;
- __LOADSIZE__: type = weak, value = __INIT_RUN__ - __STARTUP_RUN__ +
- __MOVE_LAST__ - __MOVE_START__;
}
MEMORY {
- ZP: define = yes, start = $0080, size = $001A;
- HEADER: file = %O, start = $0000, size = $0004;
- MAIN: file = %O, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S;
- MOVE: file = %O, define = yes, start = $0000, size = $FFFF;
- LC: define = yes, start = __LCADDR__, size = __LCSIZE__;
+ ZP: file = "", define = yes, start = $0080, size = $001A;
+ HEADER: file = %O, start = %S - 4, size = $0004;
+ MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S;
+ BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
+ LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__;
}
SEGMENTS {
- ZEROPAGE: load = ZP, type = zp;
- EXEHDR: load = HEADER, type = ro;
- STARTUP: load = MAIN, type = ro, define = yes;
- LOWCODE: load = MAIN, type = ro, optional = yes;
- CODE: load = MAIN, type = ro;
- RODATA: load = MAIN, type = ro;
- DATA: load = MAIN, type = rw;
- INIT: load = MAIN, type = bss, define = yes;
- BSS: load = MAIN, type = bss, define = yes;
- ONCE: load = MOVE, run = MAIN, type = ro, define = yes, optional = yes;
- LC: load = MOVE, run = LC, type = ro, optional = yes;
+ ZEROPAGE: load = ZP, type = zp;
+ EXEHDR: load = HEADER, type = ro;
+ STARTUP: load = MAIN, type = ro;
+ LOWCODE: load = MAIN, type = ro, optional = yes;
+ CODE: load = MAIN, type = ro;
+ RODATA: load = MAIN, type = ro;
+ DATA: load = MAIN, type = rw;
+ INIT: load = MAIN, type = rw;
+ ONCE: load = MAIN, type = ro, define = yes;
+ LC: load = MAIN, run = LC, type = ro, optional = yes;
+ BSS: load = BSS, type = bss, define = yes;
}
FEATURES {
CONDES: type = constructor,
.export _exit, done, return
.export __STARTUP__ : absolute = 1 ; Mark as startup
- .import zerobss
+
.import initlib, donelib
- .import callmain
+ .import zerobss, callmain
+ .import __ONCE_LOAD__, __ONCE_SIZE__ ; Linker generated
.import __LC_START__, __LC_LAST__ ; Linker generated
- .import __ONCE_RUN__, __ONCE_SIZE__ ; Linker generated
- .import __INIT_RUN__ ; Linker generated
.include "zeropage.inc"
.include "apple2.inc"
+; ------------------------------------------------------------------------
+
.segment "STARTUP"
; ProDOS TechRefMan, chapter 5.2.1:
ldx #$FF
txs ; Init stack pointer
- ; Switch in LC bank 2 for W/O.
- bit $C081
- bit $C081
-
- ; Set the source start address.
- lda #<(__INIT_RUN__ + __ONCE_SIZE__)
- ldy #>(__INIT_RUN__ + __ONCE_SIZE__)
- sta $9B
- sty $9C
-
- ; Set the source last address.
- lda #<(__INIT_RUN__ + __ONCE_SIZE__ + __LC_LAST__ - __LC_START__)
- ldy #>(__INIT_RUN__ + __ONCE_SIZE__ + __LC_LAST__ - __LC_START__)
- sta $96
- sty $97
-
- ; Set the destination last address.
- lda #<__LC_LAST__
- ldy #>__LC_LAST__
- sta $94
- sty $95
-
- ; Call into Applesoft Block Transfer Up -- which handles zero-
- ; sized blocks well -- to move the content of the LC memory area.
- jsr $D39A ; BLTU2
-
- ; Set the source start address.
- lda #<__INIT_RUN__
- ldy #>__INIT_RUN__
- sta $9B
- sty $9C
-
- ; Set the source last address.
- lda #<(__INIT_RUN__ + __ONCE_SIZE__)
- ldy #>(__INIT_RUN__ + __ONCE_SIZE__)
- sta $96
- sty $97
-
- ; Set the destination last address.
- lda #<(__ONCE_RUN__ + __ONCE_SIZE__)
- ldy #>(__ONCE_RUN__ + __ONCE_SIZE__)
- sta $94
- sty $95
+ ; Save space by putting some of the start-up code in the ONCE segment,
+ ; which can be re-used by the BSS segment, the heap and the C stack.
+ jsr init
- ; Call into Applesoft Block Transfer Up -- which handles moving
- ; overlapping blocks upwards well -- to move the ONCE segment.
- jsr $D39A ; BLTU2
+ ; Clear the BSS data.
+ jsr zerobss
- ; Delegate all further processing, to keep the STARTUP segment small.
- jsr init
+ ; Push the command-line arguments; and, call main().
+ jsr callmain
; Avoid a re-entrance of donelib. This is also the exit() entry.
_exit: ldx #<exit
; We're done
jmp done
+; ------------------------------------------------------------------------
+
.segment "ONCE"
; Save the zero-page locations that we need.
dex
bpl :-
- ; Clear the BSS data.
- jsr zerobss
-
; Save the original RESET vector.
ldx #$02
: lda SOFTEV,x
dex
bpl :-
- ; ProDOS TechRefMan, chapter 5.3.5:
- ; "Your system program should place in the RESET vector the
- ; address of a routine that ... closes the files."
- ldx #<_exit
- lda #>_exit
- jsr reset ; Setup RESET vector
-
; Check for ProDOS.
ldy $BF00 ; MLI call entry point
cpy #$4C ; Is MLI present? (JMP opcode)
: sta sp
stx sp+1
+ ; ProDOS TechRefMan, chapter 5.3.5:
+ ; "Your system program should place in the RESET vector the
+ ; address of a routine that ... closes the files."
+ ldx #<_exit
+ lda #>_exit
+ jsr reset ; Setup RESET vector
+
; Call the module constructors.
jsr initlib
- ; Switch in LC bank 2 for R/O.
+ ; Switch in LC bank 2 for W/O.
+ bit $C081
+ bit $C081
+
+ ; Set the source start address.
+ ; Aka __LC_LOAD__ iff segment LC exists.
+ lda #<(__ONCE_LOAD__ + __ONCE_SIZE__)
+ ldy #>(__ONCE_LOAD__ + __ONCE_SIZE__)
+ sta $9B
+ sty $9C
+
+ ; Set the source last address.
+ ; Aka __LC_LOAD__ + __LC_SIZE__ iff segment LC exists.
+ lda #<((__ONCE_LOAD__ + __ONCE_SIZE__) + (__LC_LAST__ - __LC_START__))
+ ldy #>((__ONCE_LOAD__ + __ONCE_SIZE__) + (__LC_LAST__ - __LC_START__))
+ sta $96
+ sty $97
+
+ ; Set the destination last address.
+ ; Aka __LC_RUN__ + __LC_SIZE__ iff segment LC exists.
+ lda #<__LC_LAST__
+ ldy #>__LC_LAST__
+ sta $94
+ sty $95
+
+ ; Call into Applesoft Block Transfer Up -- which handles zero-
+ ; sized blocks well -- to move the content of the LC memory area.
+ jsr $D39A ; BLTU2
+
+ ; Switch in LC bank 2 for R/O and return.
bit $C080
+ rts
- ; Push the command-line arguments; and, call main().
- jmp callmain
+; ------------------------------------------------------------------------
.code
.byte $65 ; Quit
.word q_param
+; ------------------------------------------------------------------------
+
.rodata
; MLI parameter list for quit
.byte $00 ; reserved
.word $0000 ; reserved
+; ------------------------------------------------------------------------
+
.data
; Final jump when we're done
done: jmp DOSWARM ; Potentially patched at runtime
+; ------------------------------------------------------------------------
+
.segment "INIT"
zpsave: .res zpspace
-
- .bss
-
rvsave: .res 3
;
.export __EXEHDR__ : absolute = 1 ; Linker referenced
- .import __LOADADDR__, __LOADSIZE__ ; Linker generated
+ .import __MAIN_START__, __MAIN_LAST__ ; Linker generated
; ------------------------------------------------------------------------
.segment "EXEHDR"
- .addr __LOADADDR__ ; Load address
- .word __LOADSIZE__ ; Load length
+ .addr __MAIN_START__ ; Load address
+ .word __MAIN_LAST__ - __MAIN_START__ ; Load length