.Com calling .com

Par cesar guerra

Supporter (15)

Portrait de cesar guerra

08-08-2018, 19:41

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 ou Inscrivez-vous pour poster

Par arnold_m

Master (173)

Portrait de arnold_m

08-08-2018, 22:43

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.

Par gdx

Enlighted (6437)

Portrait de gdx

09-08-2018, 09:32

Try it:


  • Define FCB and the adresse 0100h to load the command with functions 00Fh and 01Ah
  • Load the DOS command with function 027h, open the file, load it.
  • If parameters are need copy them to 00080h with the 16 bytes of FCBs to 0005ch and 0006ch.
  • Close the file (function 010h) and jump to 0100h.


  • Load the DOS command with functions 043h and 48h.
  • If parameters are need copy them to 00080h with the 16 bytes of FCBs to 0005ch and 0006ch.
  • Close the file (function 045h) and jump to 0100h.

Obviously do not load the command where the program runs.

Par fr3nd

Expert (112)

Portrait de fr3nd

09-08-2018, 14:35

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...


Enlighted (6093)

Portrait de NYYRIKKI

09-08-2018, 16:52

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