Table of Contents
Early mid July work on lDOS, LZEXE, and MSDebug
2025-07-13, 2025-07-14
This week + Monday some changes were added to the lDOS kernel's comloader (the MZ exe image embedded into the ldos.com file), to the LZEXE ecm fork, and to MSDebug (the ecm fork of MS-DOS's Debug).
lDOS
- comloader:
- Fix to add a cpu 8086 directive for 8086-clean code generation.
- Add mzheader.mac from lDebug.
- Support MZ exe files as payloads. (Optimistic, not yet honouring the minimum allocation.)
- Compress instsect.com file using comtoexe and lzexe.
- doc: List comtoexe and lzexe in building.
- Rename comloader binary from payload2.com to payload2.bin
- Display comloader size (the stub that loads and runs other executables).
- Add sumspace utility to determine largest minimum allocation including PSP and image.
- Align after comloader programs using the byte value 26h.
- Use sumspace to set comloader's minimum allocation.
- doc: List sumspace dependencies in building.
- Preserve original ax for flat-format executables as well. (This is a little nonsensical because we modify the command line, so the FCBs are no longer valid. May change this later.)
- Add define _COMPRESSEDCOMLOADER to choose whether to use the compressed or uncompressed instsect.
- Add code from msdos4's revision of Debug to parse the modified command line tail into the two standard FCBs and their related drive validity flags, overwriting the original value passed in ax to the comloader.
- Pass along parameters to mak.sh to NASM and the kernwrap mak.sh
LZEXE
- infoexe: Fix, calculate headersize as a longint
- infoexe: Fix, calculate and display header size as a longint
- doc: Update news-r4 with infoexe fixes.
- Update upackexe, infoexe, comtoexe, and lzexe to use named constants for the exe header field word indices (from lDebug mzheader.mac).
- Change EXESIZE to BEXESIZE to avoid a clash.
- upackexe: Add debugging output with the %DEBUG% variable.
- upackexe: Do not force 512 bytes for the header size when processing the never-packed prefix part.
- upackexe: Change a few forgotten spots for wexe constant indices.
- upackexe: Handle >512 exeExtraBytes as 512.
- lzexe: Fix, /S /J should not inline getbit function.
- Optimise two branches in LZX0 stub, one to re-use two inc instructions and the other to use a single branch plus fallthrough rather than one conditional branch and an additional unconditional branch.
- doc: Add section format describing the format of the compressed stream.
- Implement the trailing directory name to the lzexe program to specify a different output directory instead of the current directory. As stated in the changeset message: "This is a feature advertised by LZEXE v0.91e albeit it doesn't seem to really be implemented at all. Therefore I wasn't able to implement it in a compatible fashion, so I just did what seemed the right way to do it."
MSDebug
- Fix to initialise parserr to 0 rather than a random value.
- Fix, drive validity flags should always be 0 or FFh, not 1. If an FCB contains wildcards then DOS call int 21h function 2901h may return 1. This bug appears to be present in all revisions of MS-DOS Debug, but was never present in FreeDOS Debug, the original sources containing exactly the same workaround code from the very first release.
- Pick switchar support for the delim2 function from the msdos4 source revision of Debug. This queries the DOS for the switch character every time before delim2 is used (in OC_FILE and in SKIP_FILE, which are both in debcom2.nas for MSDebug), which may not be needed. However, it is compatible this way.
- Init parserr and handle in data section, move them around and use
alignbinstead ofevento discard some of the executable's trailing data. - On early error try to terminate using int 21h function 4CFFh first. This won't work on 86-DOS version 1 so we do run int 20h afterwards for that case.
- Move the badver message into the area that's re-used as a stack.
- Add initial sp check to insure there's sufficient memory allocated to the process memory block. Avoids random memory corruption if the block is smaller.
- Add a placeholder MZ executable stack object file, trailing in the linking, to silence the WarpLink warning about a missing stack. Also add
/soption to x2b2 to silence its error about a stack being present. - Updated manual:
- Update attribution year and add the E. to my initials.
- In quickstart add references to the listed sections (copied from lDebug manual).
- Update attribution lines in license.txt and in manual.
MSDebug using lzexe?
MSDebug's executable file only runs as a DOS application (not device driver nor kernel) and the program doesn't access its own executable file. Therefore, it is ideal for compression with LZEXE.
The 13_568 byte flat-format executable is enlarged by 64 bytes to 13_632 bytes when using comtoexe with its /2 switch. This then can be compressed using the LZX0 format to 11_004 bytes (80.72% of the uncompressed file left).
Aside from compression, using only comtoexe /2 is ideal for MSDebug because for 64 bytes added, it can safely be attempted to load it into a small memory block (eg UMB) without the danger of running out of memory. This was achieved intentionally by adding the SP check to MSDebug's init code where it would be found by comtoexe. (The SP check is still needed otherwise because the int 21h function 4Ah call isn't checked for errors, so the memory block better be at least this large already.)
The only downside to using comtoexe /2 is that the program can no longer be run as a flat-format executable by DOS versions that do not support the MZ exe header. However, these versions already aren't really supported, and should at best emit an informative error message.
The downsides to compressing are as usual: Longer startup load time and virtual inability to patch the binary on disk.
