johnson@noscvax.UUCP (Timothy A. Johnson) (08/31/85)
I am trying to write a procedure in TURBO Pascal which will use the DOS EXEC function call, 4BH, to execute a child program and return to the caller. I get to the child alright, but upon return, the screen goes crazy and the keyboard locks up. I'm using the TURBO procedure MSDOS to do the EXEC call. Does anyone out there have any suggestions as to how to regain proper control? Thanks. Tim Johnson Computer Sciences Corporation
Brzozowski@his-phoenix-multics.arpa (09/06/85)
The basic problem with executing the EXEC call from TURBO is the fact that the interrupt will not guarantee to restore any registers except the CS and the IP. Which means that the data, and stack segments are not through your current segment registers. Which means when you return back to TURBO all your stack and data is garbage. The solution is to push all your necessary registers and then save the SS and SP in a location in your code segment. (I would have tried this on a program I was working on a while back but I didn't have the intestinal fortitude to write such a thing in inline code...) Good luck! Gary Brz... (Brzozowski%pco@CISL-SERVICE-MULTICS)
jlt%styx.uucp@BRL.ARPA (John L. Thomas) (09/07/85)
> when you return back to TURBO all your stack and data is garbage. The > solution is to push all your necessary registers and then save the SS > and SP in a location in your code segment. Just to clear up a ?minor? point of confusion: How could the return from interrupt have happened if the SS:SP is garbage? In fact, the restoration of CS:IP comes from the return, which requires that SS:SP be correct. John -- ARPA jlt@styx UUCP ...!seismo!lognet2!styx!jlt Deathstar (415) 423-6029 SNail John L. Thomas MS-L275 POB 808 Livermore, CA 94550 * * * I deny that the preceeding has any relation to reality. * * *
brownc@utah-cs.UUCP (Eric C. Brown) (09/08/85)
In article <11416@styx.UUCP> jlt@styx.UUCP (John L. Thomas) writes: >> when you return back to TURBO all your stack and data is garbage. The >> solution is to push all your necessary registers and then save the SS >> and SP in a location in your code segment. > >Just to clear up a ?minor? point of confusion: >How could the return from interrupt have happened if the SS:SP is garbage? >In fact, the restoration of CS:IP comes from the return, which requires >that SS:SP be correct. > Well, actually, according to a note in the Zenith MS-DOS 2.0 Programmer's Utility Package, all registers (including the stack) are altered because control is returned from the executed program, not the system. My guess is that the 2.0 Exec function sets up the program exit address of the called program to point back to the calling program. Eric C. Brown brownc@utah-cs ...{ihnp4, decvax}!utah-cs!brownc Execute Programs, not People!