The code is a bit differentdr beep wrote: ↑Tue Apr 30, 2024 8:19 pm I was thinking of this loader:where the loaded code would load a RET over LOAD_PROG_BEGCode: Select all
START: call SET_FAST ; load operations to be managed in FAST mode ld sp, #4400-2 ; / ld hl, 0x4000 ; start loading data at 4000h ld hl, LOAD_PROG_BEG ; relocate loader to end of memory ld de, TARGET_LOAD ; / push de ; / ld bc, LOAD_PROG_END - LOAD_PROG_BEG ; / ldir ; _/ ret LOAD_PROG_BEG: ; this label will be at "TARGET_LOAD:" address call IN_BYTE ; ROM routine IN-BYTE loads a byte ld (hl), c ; insert assembled byte in memory jr LOAD_PROG_BEG ; (relocatable jump) db 0, 0, 0, 0 ; stack space dw start LOAD_PROG_END:
and START is the start in the loaded program.
Gonna give it a try.
Code: Select all
TARGET_LOAD equ 0x4400-4 + LOAD_PROG_BEG - LOAD_PROG_END
START:
ld sp, #4400 ; /
ld hl,program_start
push hl
call SET_FAST ; load operations to be managed in FAST mode
ld hl, LOAD_PROG_BEG ; relocate loader to end of memory
ld de, TARGET_LOAD ; /
push de ; /
ld bc, LOAD_PROG_END - LOAD_PROG_BEG ; /
ldir ; _/
ld hl, 0x4000 ; start loading data at 4000h
ret
LOAD_PROG_BEG: ; this label will be at "TARGET_LOAD:" address
call IN_BYTE ; ROM routine IN-BYTE loads a byte
ld (hl), c ; insert assembled byte in memory
jr LOAD_PROG_BEG ; (relocatable jump)
db 0, 0, 0, 0 ; stack space
LOAD_PROG_END: