cmi@dartvax.UUCP (Theo Pozzy/R. Green) (10/05/84)
Help! I am struggling to understand an apparent inconsistency in the MS/PC-DOS (2.X) operating system. I am trying to run a program by loading it in, setting up the Program Segment Prefix, registers, etc., and setting the Terminate Exit Address to my own termination trap routine. This works fine in most cases, and with most programs I try to run. If however, I run a program which uses the new DOS 04CH terminate process call, I can only run it once; the second time, I return straight to the operating system. I'm not the only one who has this problem. WordStar's run command also fails in exactly the same manner. And if you run a program loaded by DEBUG more than once, you also return to the operating system (instead of DEBUG). As an example of two short assembly language programs which excersize the bug, consider the following: ; ; This program terminates by jumping to location 0 in the Program ; Segment Prefix, which simply executes an INT 20H, a documented ; way of terminating a program. This program may be run multiple ; times under another program with no problems. ; assume ds:dseg,ss:sseg sseg segment stack 'stack' db 512 dup (?) stk equ $ sseg ends dseg segment 'data' msg db 'hello',0dh,0ah,'$' xxx dw 0 yyy dw 0 dseg ends cseg segment 'code' assume cs:cseg main: mov ax,dseg ; set up ds mov ds,ax mov ah,9 lea dx,msg int 21h mov word ptr xxx,0 mov word ptr yyy,es jmp dword ptr xxx cseg ends end The following program is the one that fails: ; ; This program terminates using the new DOS 2.X 4CH terminate process ; call. It cannot be run twice under one execution of another program; ; the second run will return straight to the operating system. ; assume ds:dseg,ss:sseg sseg segment stack 'stack' db 512 dup (?) stk equ $ sseg ends dseg segment 'data' msg db 'hello',0dh,0ah,'$' xxx dw 0 yyy dw 0 dseg ends cseg segment 'code' assume cs:cseg main: mov ax,dseg ; set up ds mov ds,ax mov ah,9 lea dx,msg int 21h mov ah,04ch mov al,0 int 21h cseg ends end I would be grateful if anyone can enlighten me as to what is going on, and hopefully how to get around this problem. Thanks in advance, Theo Pozzy Corporate Microsystems, Inc. USENET ...!decvax!dartvax!cmi CSNET cmi@dartmouth