We now copy intializer to initialized and then pack common, fonts, discard etc
over data. That has two impacts
- your crt0.s needs to copy from s__DATA now
- your crt0.s ordering needs to put DATA last in the main block
It also saves us about 8K and neatly avoids any issues with overlapping memory
areas. That makes it worth the pain.
.area _VIDEO
.area _CONST
.area _INITIALIZED
- .area _INITIALIZER
.area _DATA
.area _BSEG
.area _BSS
.area _HEAP
+ .area _INITIALIZER
; note that areas below here may be overwritten by the heap at runtime, so
; put initialisation stuff in here
.area _GSINIT
start: di
ld sp, #kstack_top
; move the common memory where it belongs
- ld hl, #s__INITIALIZER
+ ld hl, #s__DATA
ld de, #s__COMMONMEM
ld bc, #l__COMMONMEM
ldir
.area _CODE2
.area _VIDEO
.area _CONST
- .area _DATA
.area _INITIALIZED
+ .area _DATA
+ .area _INITIALIZER
.area _BSEG
.area _BSS
.area _HEAP
; note that areas below here may be overwritten by the heap at runtime, so
; put initialisation stuff in here
- .area _INITIALIZER
.area _GSINIT
.area _GSFINAL
.area _COMMONMEM
start:
ld sp, #kstack_top
; move the common memory where it belongs
- ld hl, #s__INITIALIZER
+ ld hl, #s__DATA
+ push hl
ld de, #s__COMMONMEM
ld bc, #l__COMMONMEM
ldir
ld bc, #l__DISCARD
ldir
; then zero the data area
- ld hl, #s__DATA
+ pop hl ; s__DATA
ld de, #s__DATA + 1
ld bc, #l__DATA - 1
ld (hl), #0
/* Pack any common memory on the end of the main code/memory if its
relocated */
if (!s__DISCARD || pack_discard) {
- base = s__INITIALIZER;
+ base = s__DATA;
tail = l__COMMONMEM;
memcpy(out + base, buf + s__COMMONMEM,
l__COMMONMEM);
if (reloc == 0 && end < s__COMMONMEM + l__COMMONMEM)
end = s__COMMONMEM + l__COMMONMEM;
- /* Packed image with common over initializer */
+ /* Packed image with common over data */
if (!s__DISCARD || pack_discard) {
end = base;
printf("\nPacked image %d bytes, for RAM target\n",