Don't save and restore the zero page locations used.

Saves 19 bytes code (in the exe file) and reduces memory footprint
of the program by 45 bytes (code & bss).
This commit is contained in:
Christian Groessler
2013-07-02 19:55:00 +02:00
parent 5edcd639e0
commit 7ebaec1802
3 changed files with 6 additions and 29 deletions

View File

@@ -19,7 +19,6 @@ SEGMENTS {
CODE: load = RAM, type = ro, define = yes; CODE: load = RAM, type = ro, define = yes;
RODATA: load = RAM, type = ro; RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw; DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
BSS: load = RAM, type = bss, define = yes; BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp; ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = zp, optional = yes; EXTZP: load = ZP, type = zp, optional = yes;

View File

@@ -19,7 +19,6 @@ SEGMENTS {
CODE: load = RAM, type = ro, define = yes; CODE: load = RAM, type = ro, define = yes;
RODATA: load = RAM, type = ro; RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw; DATA: load = RAM, type = rw;
ZPSAVE: load = RAM, type = bss, define = yes;
BSS: load = RAM, type = bss, define = yes; BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp; ZEROPAGE: load = ZP, type = zp;
EXTZP: load = ZP, type = zp, optional = yes; EXTZP: load = ZP, type = zp, optional = yes;

View File

@@ -13,7 +13,7 @@
.import initlib, donelib .import initlib, donelib
.import callmain, zerobss .import callmain, zerobss
.import __STARTUP_LOAD__, __ZPSAVE_LOAD__ .import __STARTUP_LOAD__, __BSS_LOAD__
.import __RESERVED_MEMORY__ .import __RESERVED_MEMORY__
.include "zeropage.inc" .include "zeropage.inc"
@@ -26,7 +26,7 @@
.word $FFFF .word $FFFF
.word __STARTUP_LOAD__ .word __STARTUP_LOAD__
.word __ZPSAVE_LOAD__ - 1 .word __BSS_LOAD__ - 1
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
; Actual code ; Actual code
@@ -40,14 +40,6 @@
; Real entry point: ; Real entry point:
; Save the zero page locations we need
ldx #zpspace-1
L1: lda sp,x
sta zpsave,x
dex
bpl L1
; Clear the BSS data ; Clear the BSS data
jsr zerobss jsr zerobss
@@ -126,17 +118,9 @@ _exit: jsr donelib ; Run module destructors
lda appmsav+1 lda appmsav+1
sta APPMHI+1 sta APPMHI+1
; Copy back the zero page stuff
ldx #zpspace-1
L2: lda zpsave,x
sta sp,x
dex
bpl L2
; Turn on cursor ; Turn on cursor
inx ldx #0
stx CRSINH stx CRSINH
; Back to DOS ; Back to DOS
@@ -147,12 +131,6 @@ L2: lda zpsave,x
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
.segment "ZPSAVE"
zpsave: .res zpspace
; ------------------------------------------------------------------------
.bss .bss
spsave: .res 1 spsave: .res 1
@@ -160,7 +138,8 @@ appmsav: .res 1
old_shflok: .res 1 old_shflok: .res 1
old_lmargin: .res 1 old_lmargin: .res 1
.segment "AUTOSTRT"
.word RUNAD ; defined in atari.h .segment "AUTOSTRT"
.word RUNAD ; defined in atari.inc
.word RUNAD+1 .word RUNAD+1
.word __STARTUP_LOAD__ + 1 .word __STARTUP_LOAD__ + 1