rename byte [SDA + 25Ch] from _tsr to _term_type, fix int 24h rc

This fixes int 24h abort to set the return code to 200h.
The ErrorMode misuse is apparently necessary, but was not
sufficient to set the return code.
This commit is contained in:
E. C. Masloch 2025-08-22 17:43:07 +02:00 committed by Kenneth J Davis
parent 2b54761e28
commit 3c751e2e28
6 changed files with 26 additions and 19 deletions

View File

@ -41,6 +41,7 @@ segment HMA_TEXT
extern _user_r
extern _ErrorMode
extern _InDOS
extern _term_type
%IFDEF WIN31SUPPORT
extern _winInstanced
%ENDIF ; WIN31SUPPORT
@ -264,11 +265,11 @@ reloc_call_int21_handler:
; NB: At this point, SS != DS and won't be set that way
; until later when which stack to run on is determined.
;
int21_reentry:
Protect386Registers
mov dx,[cs:_DGROUP_]
mov ds,dx
mov byte [_term_type], 0 ; reset termination type
int21_reentry: ; entered here from int 24h abort, ds = dx => DGROUP
Protect386Registers
cmp ah,33h
je int21_user
cmp ah,50h
@ -760,4 +761,6 @@ CritErrAbort:
mov ax,4C00h
mov [bp+reg_ax],ax
sti
mov byte [_term_type], 2 ; set int 24h abort error
mov dx, ds
jmp int21_reentry ; restart the system call

View File

@ -307,7 +307,7 @@ extern BYTE
ASM internal_data[], /* sda areas */
ASM swap_always[], /* " " */
ASM swap_indos[], /* " " */
ASM tsr, /* true if program is TSR */
ASM term_type, /* 0 normal, 1 ^C, 2 int 24h, 3 TSR */
ASM break_flg, /* true if break was detected */
ASM break_ena; /* break enabled flag */
extern void FAR * ASM dta; /* Disk transfer area (kludge) */

View File

@ -811,7 +811,7 @@ dispatch:
case 0x31:
DosMemChange(cu_psp, lr.DX < 6 ? 6 : lr.DX, 0);
return_code = lr.AL | 0x300;
tsr = TRUE;
term_type = 3; /* ecm: TSR terminate */
return_user();
break;
@ -1104,18 +1104,11 @@ dispatch:
/* End Program */
case 0x4c:
tsr = FALSE;
rc = 0;
if (ErrorMode)
{
ErrorMode = FALSE;
rc = 0x200;
}
else if (break_flg)
{
if (break_flg) {
break_flg = FALSE;
rc = 0x100;
term_type = 1;
}
rc = term_type << 8;
return_code = lr.AL | rc;
if (DosMemCheck() != SUCCESS)
panic("MCB chain corrupted");
@ -1784,7 +1777,7 @@ VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp,
int sp, int bx, int dx, int cx, int ax,
int ip, int cs, int flags)
{
tsr = FALSE;
term_type = 1;
return_mode = 1;
return_code = -1;
mod_sto(CTL_C);

View File

@ -838,8 +838,12 @@ _Server_Call db 0 ;252 - Server call Func 5D sub 0
; Pad to 05CCh
times (25ch - ($ - _internal_data)) db 0
global _tsr ; used by break and critical error
_tsr db 0 ;25C - handlers during termination
global _term_type ; used by break and critical error
_term_type db 0 ;25C - handlers during termination
; ecm: 00h = normal terminate,
; 01h = control-c terminate,
; 02h = critical error abort,
; 03h = TSR terminate
db 0 ;25D - padding
global term_psp
term_psp dw 0 ;25E - 0??

View File

@ -34,6 +34,7 @@
extern _user_r
extern _break_flg ; break detected flag
extern _term_type
extern _int21_handler ; far call system services
%include "stacks.inc"
@ -257,6 +258,12 @@ _spawn_int23:
push ds ;; we need DGROUP
mov ds, [cs:_DGROUP_]
inc byte [_break_flg]
mov byte [_term_type], 1
; ecm: This is overwritten in the int 21h handler,
; but is passed from the int 23h caller to the
; terminate code in MS-DOS by writing this.
; For us, break_flg is used in function 4Ch to
; re-set term_type to 1 later.
pop ds
xor ah, ah ;; clear ah --> perform DOS-00 --> terminate

View File

@ -593,7 +593,7 @@ VOID return_user(void)
/* might be a good idea to do that after closing
but doesn't help NET either TE */
if (!tsr && p->ps_parent != cu_psp)
if (term_type != 3 && p->ps_parent != cu_psp)
{
network_redirector(REM_CLOSEALL);
for (i = 0; i < p->ps_maxfiles; i++)