If you had to set the Ram_Top to make room for an ASM routine, in Basic:
Exemple @ 78FC
POKE 16388,252 ($FC)
POKE 16389,120 ($78)
And NEW
But, if you had to copy an ASM code beyond this Ram_Top, before the reset, the code will be corrupt by the "NEW" jump command.
In fact, the called ASM code @$3C3, "New"... jump to the Slow/Fast ROM routine, and will tag recalled address in the old SP offset !
This tag will corrupt your code, if you forgot to keep free spaces at the end of the memory...
Code: Select all
03C3 CD;E7;02 CALL $02E7 ; [SET-FAST];NEW ; <-- This CALL will corrupt your code.
03C6 ED;4B;04;40 LD BC,($4004) ; GET RAM-TOP
03CA 0B DEC BC
03CB 60 LD H,B ; RAM-CHECK
03CC 69 LD L,C
03CD 3E;3F LD A,$3F
03CF 36;02 LD (HL),$02 ; RAM-FILL
03D1 2B DEC HL
(with a jump "JP"... not another CALL !)
Code: Select all
CALL $02E7 ; Set to FAST
LD (IY+4),$FC ; Set the RAM_top ($4000+4)
LD (IY+5),$78 ; in $78FC ($4000+5)
LD HL,$4082 ; Source offset (your own code in REM)
LD DE,$78FC ; Target offset (Future location)
LD BC,$0703 ; Code length.
LDIR ; COPY HL to DE (length=BC)
LD SP,$78FA ; You Ram_top-2 bytes
JP $03C6 ; [NEW+3]*BIOS ROM*
Have fun.