Resuelto el averiguar como sucede:
De
http://www.cpcwiki.eu/index.php/BIOS_Ca ... _Functions
Machine Pack Boot Program
BD13 MC_BOOT_PROGRAM ;in: HL=loader_callback, out: starts program
Loads and starts a BINARY program, typically used when typing RUN"filename.bin" under BASIC. The callback should load the program from whatever source (CAS, DISK, or elsewhere), and should then return CY=1=okay & HL=entrypoint (or HL=0000h to reboot the BASIC ROM), or CY=0=failed. If the callback returns CY=1 then the program (or BASIC ROM) is started via MC_START_PROGRAM, otherwise, when CY=0, "*** PROGRAM LOAD FAILED ***" is displayed, and the OS (ie. typically BASIC) is restarted.
Machine Pack Start Program
BD16 MC_START_PROGRAM ;in: HL=entrypoint (0000h=BASIC), C=ROMcfg
Starts a BINARY program, typically used when typing RUN"filename.bin" under BASIC (expecting that the file is already loaded into memory). The function resets all BIOS memory, sets SP=C000h, DE=LORAM=0040h, HL=BAS_HIRAM=ABFFh, BC=BIN_HIRAM=B0FFh, and does then call the entrypoint (incoming C:HL) via RST 18h, if incoming HL was zero then it calls 0:C006h (ie. reboots the BASIC ROM). Observe that the program is started with only the raw BIOS initialized; but without extensions like AMSDOS. To install them (if needed), the entrypoint function should set HL=BC (to deallocate BASIC RAM), then call KL_ROM_WALK (to install all extension ROMs) or, set C=07h and call KL_INIT_BACK (to install only AMSDOS).
Estas dos funciones se llaman secuencialmente desde la orden RUN"code.bin". La primera carga y la segunda lo ejecuta, pero antes de hacerle el call, nos lia esto:
The function resets all BIOS memory, sets SP=C000h, DE=LORAM=0040h, HL=BAS_HIRAM=ABFFh, BC=BIN_HIRAM=B0FFh, and does then call the entrypoint
Vamos, que resetea la pila y deja en DE, HL y BC parametros para saber el HIMEM del BASIC, y otro ¿himem de binarios? Y de paso desactiva todas las ROMS (Amsdos entre ellas) por lo que da mas o menos por hecho que el ejecutable es para no volver de el salvo que sea por un hard reset
Va a tocar hacer demasiado para currarse un "retorno" limpio... En el peor de los casos deberia ser un KL_ROM_WALK de esos y reejecutar BASIC (perdiendo el programa BASIC en RAM, pero eso lo podemos dar por hecho al usar el BASIC como una especie de shell)