mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Merge pull request #279 from greg-king5/atmos-reconfig
Convert the Atmos configuration to the new constructor segment model.
This commit is contained in:
commit
c0e82f4200
@ -11,22 +11,22 @@ MEMORY {
|
|||||||
ZP: file = "", define = yes, start = $00E2, size = $001A;
|
ZP: file = "", define = yes, start = $00E2, size = $001A;
|
||||||
TAPEHDR: file = %O, type = ro, start = $0000, size = $001F;
|
TAPEHDR: file = %O, type = ro, start = $0000, size = $001F;
|
||||||
BASHEAD: file = %O, define = yes, start = $0501, size = $000D;
|
BASHEAD: file = %O, define = yes, start = $0501, size = $000D;
|
||||||
MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__ - __STACKSIZE__;
|
MAIN: file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__;
|
||||||
|
BSS: file = "", start = __ONCE_RUN__, size = __RAMEND__ - __STACKSIZE__ - __ONCE_RUN__;
|
||||||
}
|
}
|
||||||
SEGMENTS {
|
SEGMENTS {
|
||||||
ZEROPAGE: load = ZP, type = zp;
|
ZEROPAGE: load = ZP, type = zp;
|
||||||
TAPEHDR: load = TAPEHDR, type = ro;
|
TAPEHDR: load = TAPEHDR, type = ro;
|
||||||
BASHDR: load = BASHEAD, type = ro, define = yes, optional = yes;
|
BASHDR: load = BASHEAD, type = ro, optional = yes;
|
||||||
STARTUP: load = MAIN, type = ro;
|
STARTUP: load = MAIN, type = ro;
|
||||||
LOWCODE: load = MAIN, type = ro, optional = yes;
|
LOWCODE: load = MAIN, type = ro, optional = yes;
|
||||||
CODE: load = MAIN, type = ro;
|
CODE: load = MAIN, type = ro;
|
||||||
RODATA: load = MAIN, type = ro;
|
RODATA: load = MAIN, type = ro;
|
||||||
ONCE: load = MAIN, type = ro, optional = yes;
|
|
||||||
DATA: load = MAIN, type = rw;
|
DATA: load = MAIN, type = rw;
|
||||||
INIT: load = MAIN, type = rw, optional = yes;
|
INIT: load = MAIN, type = rw;
|
||||||
ZPSAVE1: load = MAIN, type = rw, define = yes; # ZPSAVE1, ZPSAVE2 must be together
|
ONCE: load = MAIN, type = ro, define = yes;
|
||||||
ZPSAVE2: load = MAIN, type = bss; # see "libsrc/atmos/crt0.s"
|
BASTAIL: load = MAIN, type = ro, optional = yes;
|
||||||
BSS: load = MAIN, type = bss, define = yes;
|
BSS: load = BSS, type = bss, define = yes;
|
||||||
}
|
}
|
||||||
FEATURES {
|
FEATURES {
|
||||||
CONDES: type = constructor,
|
CONDES: type = constructor,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;
|
;
|
||||||
; 2010-11-14, Ullrich von Bassewitz
|
; 2010-11-14, Ullrich von Bassewitz
|
||||||
; 2014-09-06, Greg King
|
; 2016-03-17, Greg King
|
||||||
;
|
;
|
||||||
; This module supplies a small BASIC stub program that uses CALL
|
; This module supplies a small BASIC stub program that uses CALL
|
||||||
; to jump to the machine-language code that follows it.
|
; to jump to the machine-language code that follows it.
|
||||||
@ -22,3 +22,13 @@
|
|||||||
.byte $00 ; End of BASIC line
|
.byte $00 ; End of BASIC line
|
||||||
Next: .addr $0000 ; BASIC program end marker
|
Next: .addr $0000 ; BASIC program end marker
|
||||||
Start:
|
Start:
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
; This padding is needed by a bug in the ROM.
|
||||||
|
; (The CLOAD command starts BASIC's variables table on top of the last byte
|
||||||
|
; that was loaded [instead of at the next address].)
|
||||||
|
|
||||||
|
.segment "BASTAIL"
|
||||||
|
|
||||||
|
.byte 0
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
|
|
||||||
;--------------------------------------------------------------------------
|
;--------------------------------------------------------------------------
|
||||||
; Put this constructor into a segment that can be re-used by programs.
|
; Put this constructor into a segment whose space
|
||||||
|
; will be re-used by BSS, the heap, and the C stack.
|
||||||
;
|
;
|
||||||
.segment "ONCE"
|
.segment "ONCE"
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@
|
|||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Switch the cursor off. Code goes into the ONCE segment
|
; Switch the cursor off. Code goes into the ONCE segment,
|
||||||
; which may be reused after it is run.
|
; which will be reused after it is run.
|
||||||
|
|
||||||
.segment "ONCE"
|
.segment "ONCE"
|
||||||
|
|
||||||
|
@ -2,14 +2,15 @@
|
|||||||
; Startup code for cc65 (Oric version)
|
; Startup code for cc65 (Oric version)
|
||||||
;
|
;
|
||||||
; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
|
; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
|
||||||
; 2015-01-09, Greg King
|
; 2016-03-18, Greg King
|
||||||
;
|
;
|
||||||
|
|
||||||
.export _exit
|
.export _exit
|
||||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||||
|
|
||||||
.import initlib, donelib
|
.import initlib, donelib
|
||||||
.import callmain, zerobss
|
.import callmain, zerobss
|
||||||
.import __MAIN_START__, __MAIN_SIZE__, __STACKSIZE__
|
.import __MAIN_START__, __MAIN_SIZE__
|
||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
.include "atmos.inc"
|
.include "atmos.inc"
|
||||||
@ -19,39 +20,17 @@
|
|||||||
|
|
||||||
.segment "STARTUP"
|
.segment "STARTUP"
|
||||||
|
|
||||||
; Save the zero-page area that we're about to use.
|
|
||||||
|
|
||||||
ldx #zpspace-1
|
|
||||||
L1: lda sp,x
|
|
||||||
sta zpsave,x
|
|
||||||
dex
|
|
||||||
bpl L1
|
|
||||||
|
|
||||||
; Clear the BSS data.
|
|
||||||
|
|
||||||
jsr zerobss
|
|
||||||
|
|
||||||
; Currently, color isn't supported on the text screen.
|
|
||||||
; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
|
|
||||||
|
|
||||||
lda STATUS
|
|
||||||
sta stsave
|
|
||||||
and #%11011111
|
|
||||||
sta STATUS
|
|
||||||
|
|
||||||
; Save some system stuff; and, set up the stack.
|
|
||||||
|
|
||||||
tsx
|
tsx
|
||||||
stx spsave ; Save system stk ptr
|
stx spsave ; Save system stk ptr
|
||||||
|
|
||||||
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
; Save space by putting some of the start-up code in a segment
|
||||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
; that will be re-used.
|
||||||
sta sp
|
|
||||||
stx sp+1 ; Set argument stack ptr
|
|
||||||
|
|
||||||
; Call the module constructors.
|
jsr init
|
||||||
|
|
||||||
jsr initlib
|
; Clear the BSS variables (after the constructors have been run).
|
||||||
|
|
||||||
|
jsr zerobss
|
||||||
|
|
||||||
; Push the command-line arguments; and, call main().
|
; Push the command-line arguments; and, call main().
|
||||||
|
|
||||||
@ -70,7 +49,7 @@ _exit: jsr donelib
|
|||||||
|
|
||||||
; Copy back the zero-page stuff.
|
; Copy back the zero-page stuff.
|
||||||
|
|
||||||
ldx #zpspace-1
|
ldx #zpspace - 1
|
||||||
L2: lda zpsave,x
|
L2: lda zpsave,x
|
||||||
sta sp,x
|
sta sp,x
|
||||||
dex
|
dex
|
||||||
@ -81,28 +60,42 @@ L2: lda zpsave,x
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
|
; Put this code in a place that will be re-used by BSS, the heap,
|
||||||
|
; and the C stack.
|
||||||
|
|
||||||
.segment "ZPSAVE1"
|
.segment "ONCE"
|
||||||
|
|
||||||
zpsave:
|
; Save the zero-page area that we're about to use.
|
||||||
|
|
||||||
; This padding is needed by a bug in the ROM.
|
init: ldx #zpspace - 1
|
||||||
; (The CLOAD command starts BASIC's variables table on top of the last byte
|
L1: lda sp,x
|
||||||
; that was loaded [instead of at the next address].)
|
sta zpsave,x
|
||||||
; This is overlaid on a buffer, so that it doesn't use extra space in RAM.
|
dex
|
||||||
|
bpl L1
|
||||||
|
|
||||||
.byte 0
|
; Currently, color isn't supported on the text screen.
|
||||||
|
; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
|
||||||
|
|
||||||
; The segments "ZPSAVE1" and "ZPSAVE2" always must be together.
|
lda STATUS
|
||||||
; They create a single object (the zpsave buffer).
|
sta stsave
|
||||||
|
and #%11011111
|
||||||
|
sta STATUS
|
||||||
|
|
||||||
.segment "ZPSAVE2"
|
; Set up the C stack.
|
||||||
|
|
||||||
.res zpspace - 1
|
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
|
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
|
sta sp
|
||||||
|
stx sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
|
; Call the module constructors.
|
||||||
|
|
||||||
|
jmp initlib
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
.bss
|
.segment "INIT"
|
||||||
|
|
||||||
spsave: .res 1
|
spsave: .res 1
|
||||||
stsave: .res 1
|
stsave: .res 1
|
||||||
|
zpsave: .res zpspace
|
||||||
|
@ -18,7 +18,7 @@ REM = $9D ; BASIC token-code
|
|||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;---------------------------------------------------------------------------
|
||||||
; Get possible command-line arguments. Goes into the special ONCE segment,
|
; Get possible command-line arguments. Goes into the special ONCE segment,
|
||||||
; which may be reused after the startup code is run
|
; which will be reused after the startup code is run.
|
||||||
|
|
||||||
.segment "ONCE"
|
.segment "ONCE"
|
||||||
|
|
||||||
@ -119,8 +119,6 @@ done: lda #<argv
|
|||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
; These arrays are zeroed before initmainargs is called.
|
|
||||||
|
|
||||||
.segment "INIT"
|
.segment "INIT"
|
||||||
|
|
||||||
term: .res 1
|
term: .res 1
|
||||||
@ -129,6 +127,7 @@ args: .res SCREEN_XSIZE * 2 - 1
|
|||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
||||||
|
; This array has zeroes when initmainargs starts.
|
||||||
; char* argv[MAXARGS+1]={name};
|
; char* argv[MAXARGS+1]={name};
|
||||||
|
|
||||||
argv: .addr name
|
argv: .addr name
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;
|
;
|
||||||
; Based on code by Debrune Jérôme <jede@oric.org>
|
; Based on code by Debrune Jérôme <jede@oric.org>
|
||||||
; 2015-01-08, Greg King
|
; 2016-03-17, Greg King
|
||||||
;
|
;
|
||||||
|
|
||||||
; The following symbol is used by the linker config. file
|
; The following symbol is used by the linker config. file
|
||||||
@ -8,7 +8,8 @@
|
|||||||
.export __TAPEHDR__:abs = 1
|
.export __TAPEHDR__:abs = 1
|
||||||
|
|
||||||
; These symbols, also, come from the configuration file.
|
; These symbols, also, come from the configuration file.
|
||||||
.import __BASHDR_LOAD__, __ZPSAVE1_LOAD__, __AUTORUN__, __PROGFLAG__
|
.import __AUTORUN__, __PROGFLAG__
|
||||||
|
.import __BASHEAD_START__, __MAIN_LAST__
|
||||||
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
@ -23,8 +24,8 @@
|
|||||||
.byte $00 ; $2AF
|
.byte $00 ; $2AF
|
||||||
.byte <__PROGFLAG__ ; $2AE Language flag ($00=BASIC, $80=machine code)
|
.byte <__PROGFLAG__ ; $2AE Language flag ($00=BASIC, $80=machine code)
|
||||||
.byte <__AUTORUN__ ; $2AD Auto-run flag ($C7=run, $00=only load)
|
.byte <__AUTORUN__ ; $2AD Auto-run flag ($C7=run, $00=only load)
|
||||||
.dbyt __ZPSAVE1_LOAD__ ;$2AB Address of end of file
|
.dbyt __MAIN_LAST__ - 1 ; $2AB Address of end of file
|
||||||
.dbyt __BASHDR_LOAD__ ; $2A9 Address of start of file
|
.dbyt __BASHEAD_START__ ; $2A9 Address of start of file
|
||||||
.byte $00 ; $2A8
|
.byte $00 ; $2A8
|
||||||
|
|
||||||
; File name (a maximum of 17 characters), zero-terminated
|
; File name (a maximum of 17 characters), zero-terminated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user