How could a .com program call another .com program and pass the control to it? Is there a BDOS function? I did not find any.
Login sesión o register para postear comentarios
How could a .com program call another .com program and pass the control to it? Is there a BDOS function? I did not find any.
If you do not need the first program to resume, you can just set up the arguments at 0x80 with (partial) fcb's at ox5c and 0x6c load the other .com at 0x100 and jump to 0x100 (addresses from memory, check with documentation).
If you want the first program to resume after the second has finished, you'll need to store the state of the first program and set up an environment that will restore and resume it. For MSXDOS2 an example implementation can be found in the make tool.
Try it:
DOS1/DOS2:
DOS2:
Obviously do not load the command where the program runs.
I recently asked the same question on this thread: MSX-DOS create and execute child process and also found some more insightful information here: Help with ASM code (executing external program).
For someone with limited ASM knowledge like myself (I'm only programing with SDCC so far) it looks like a very difficult thing to do, specially resuming back to the previous state...
I'll check the make source code to see if I'm able to implement it but it'd be really cool to have a library to automate the process...
I think best way to learn how to handle this is to look COMMAND2.COM source...
From what I know the important parts before launching are:
- Call fork to child process
- Store your program: Reserve page in mapper if needed and store critical parts to end of TPA (ie. COMMAND2.COM stores it self right below MSXDOS2.SYS)
- Fill the parameters to #80 and those unopened FCB's to #5C & #6C
- Define "PROGRAM" & "PARAMETERS" environment variables (for DOS2 progs)
- Use "DEFINE ABORT EXIT ROUTINE" (#63) to capture exit of the program you are going to launch
- Define "soft boot" jump to address 0
- Load the program to TPA (#100 -> )
- Jump to #100 (make sure there is terminate routine on stack)
On return:
- Restore SP (it may be anywhere)
- Call join to close opened file handles
- Restore your program & the changes you made on launch
¿Aún no tienes una cuenta? ¡Conviértete en un amigo-MSX y registra tu cuenta!