Question

In the end of my program I have an option to restart the program.

To perform this option, I need to reset some of my variables to ensure that there will not be any problems.

I want to ask if there is an interrupt or function (or else) that will be able to restart/reload the program?

If it was not clear, I'm using DOS OS (on dosbox).

Was it helpful?

Solution 2

You can run your program once more as child process (dont forget to reduce memory allocated by current process before running child process).

OTHER TIPS

I don't think there is any DOS system call to restart a program, the same way there's no such system call even in modern OSs (AFAIK, correct me if I'm wrong).

Simple reseting the start values of some variables stored in a the data segment without terminating and restarting the program.

Numberone = 1
Numbertwo = 2
Numberthree = 3

VALUE1 DD Numberone
VALUE2 DD Numbertwo
VALUE3 DD Numberthree

mov DWORD PTR[VALUE1], Numberone
mov DWORD PTR[VALUE2], Numbertwo
mov DWORD PTR[VALUE3], Numberthree

With terminating and restarting the program: Like "Egor Skriptunoff" said with the "INT 21H Function 4B00H" it is possible to load, start and execute a programm as a child, so we can build with it a program that can start and also restart other .exe or .com programs, like one part of a file commander clone.

If the child program terminate with an errorlevel byte placed in the AL-Register for signaling for to restart with our own special value, then the mother program can check it (like within a batchfile) and can restart the program soon again, indirect controlled by the child program.

Ralf Browns interrupt list(RBIL): inter61b.zip->INTERRUP.G

--------D-214B-------------------------------
INT 21 - DOS 2+ - "EXEC" - LOAD AND/OR EXECUTE PROGRAM
AH = 4Bh
AL = type of load
    00h load and execute
    01h load but do not execute
    03h load overlay (see #01591)
    04h load and execute in background (European MS-DOS 4.0 only)
    "Exec & Go" (see also AH=80h)
DS:DX -> ASCIZ program name (must include extension)
ES:BX -> parameter block (see #01590,#01591,#01592)
CX = mode (subfunction 04h only)
    0000h child placed in zombie mode after termination
    0001h child's return code discarded on termination
Return: CF clear if successful
    BX,DX destroyed

...cut...

Format of EXEC parameter block for AL=00h,01h,04h:
Offset  Size    Description (Table 01590)
 00h    WORD    segment of environment to copy for child process (copy caller's
      environment if 0000h)
 02h    DWORD   pointer to command tail to be copied into child's PSP
 06h    DWORD   pointer to first FCB to be copied into child's PSP
 0Ah    DWORD   pointer to second FCB to be copied into child's PSP
 0Eh    DWORD   (AL=01h) will hold subprogram's initial SS:SP on return
 12h    DWORD   (AL=01h) will hold entry point (CS:IP) on return
SeeAlso: #01591,#01592

Example of a parameter block:

PARBLOCK  equ THIS WORD      ; parameter-block for the EXEC-Function
          DW 0               ; same environment-block
          DW OFFSET COMLINE  ; Offset-address and
          DW SEG COD         ;  segmentaddress of the command line
          DD 0               ; no date in PSP #1
          DD 0               ; no data in PSP #2
COMLINE   DB 80h dup (0)     ; command line

Hint: We have to save the addresses of the SS and SP register pair into two reserved words in our codesegment of our mother program before calling this interrupt. So if the child was normaly terminated we can get back our stack pointer to the mother program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top