Skip to content

Conversation

ecm-pushbx
Copy link
Contributor

Fixes #210, fixes #212, and fixes #213.

Tested both the gcc-ia16 and OpenWatcom 386 builds using my debugger, testkern (the fs/gs preserved on int 24h repeat check), testfill (just the TSR terminate return code 300h), and testabrt (abort a self-parented process and get return code 200h).

Copies of the more verbose commit messages:

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.

set byte [SDA + 39h] during process termination, turn abort to fail

This is compatible to lMS-DOS which sets the flag before running int 2Fh function 1122h 1 and clears it after closing handles and freeing memory 2, before branching to the Parent Return Address.

The flag turns any int 24h abort response into a fail instead, to avoid iterating infinitely during file handle closing.

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 is compatible to lMS-DOS which sets the flag before running
int 2Fh function 1122h [1] and clears it after closing handles and
freeing memory [2], before branching to the Parent Return Address.

The flag turns any int 24h abort response into a fail instead, to
avoid iterating infinitely during file handle closing.

[1]: https://hg.pushbx.org/ecm/msdos4/file/c057c6a1c9ad/src/DOS/ctrlc.nas#l752
[2]: https://hg.pushbx.org/ecm/msdos4/file/c057c6a1c9ad/src/DOS/ctrlc.nas#l829
@ecm-pushbx
Copy link
Contributor Author

ecm-pushbx commented Aug 22, 2025

The ErrorMode misuse is apparently necessary, but was not sufficient to set the return code.

If error mode isn't set then the code branches so that it increments InDOS, which ends up with InDOS = 2 here:

cmp byte [_ErrorMode],0

InDOS is decremented, not reset to zero, in

kernel/kernel/task.c

Lines 616 to 617 in 032523a

if (InDOS)
--InDOS;

The int21_service function resets error mode early for function 4Ch:

kernel/kernel/inthndlr.c

Lines 475 to 478 in 032523a

if (/*ErrorMode && */lr.AH > 0x0c && lr.AH != 0x30 && lr.AH != 0x59)
{
/*if (ErrorMode)*/ ErrorMode = 0;
}

That means it isn't set any longer in

kernel/kernel/inthndlr.c

Lines 1105 to 1113 in 032523a

/* End Program */
case 0x4c:
tsr = FALSE;
rc = 0;
if (ErrorMode)
{
ErrorMode = FALSE;
rc = 0x200;
}

@ecm-pushbx
Copy link
Contributor Author

After a usual Error Mode int 21h call, InDOS is not decremented to match it not being incremented at the beginning:

jmp short int21_exit_nodec

In lMS-DOS we clear InDOS on process termination, overwriting it with a zero, rather than only decrementing it.

Also, lMS-DOS doesn't re-enter the main int 21h handler again to do the int 24h abort, so it can't incorrectly increment InDOS again.

Unlike FreeDOS, lMS-DOS resets Error Mode to zero after int 24h has been called, not setting it again for the abort afterwards.

@ecm-pushbx
Copy link
Contributor Author

Interestingly, in https://hg.pushbx.org/ecm/msdos4/file/c057c6a1c9ad/src/DOS/disp.nas#l465 functions 00h, 59h, and > 0Ch are handled variously. The 00h differs from FreeDOS, and 59h is handled specifically in a different way. FreeDOS also detects function 30h. Should investigate if MS-DOS v5 also handles function 30h differently.

@PerditionC PerditionC merged commit 80d1409 into FDOS:master Aug 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants