Table of Contents
Mid early September work on the debugger
2026-09-13
This week I mostly worked on enabling different build options for the debugger, including _SYMBOLIC. One fix to the immediate assembler (immasm) also got done.
The symbolic option changes to the debugger depend on an earlier change:
Add symsnip directory include option to the makefile. This is a step towards supporting the _LINK _SYMBOLIC build, albeit not sufficient. It may eventually come down to including symsnip (and scanptab) as subrepos of the lDebug repo so that the makefile knows exactly where to find these source files, so that the dependency checks can be done in the expected way.
For now, the symsnip files live in a separate repo, just like scanptab and lmacros. They're not properly tracked as dependencies by the makefile. Moving some or all of these into hg subrepos would fix the path relative to the ldebug/source/ directory so that the proper makefile dependencies could be added. Or, the relative path could be hardcoded without using subrepos, assuming that the other repos are in sister directories of the ldebug repo.
lDebug (experimental repo)
- doc: Delete some superfluous blank lines in eldcomlevels section, left over from editing.
- Fix JMP FAR imm and CALL FAR imm in the immediate assembler to use the current debuggee CS as destination segment or selector, rather than the immasm code seg/sel. This change had me review much of the immediate assembler code.
The immediate assembler is rather baroque, particularly its handling of the special cases involving ip, cs, or ds. One question I had is how is a near JMP imm handled. Tracing an immasm command I found that the rel8 flag (dif6_immasm_rel8) is set for such an instruction. How so? It turned out that a near JMP imm first runs the assembler's code for a short JMP imm. This sets the immasm_rel8_target variable, and the flag, and then actually assembles using a rel8 of 0 so the short JMP form (EBh) is always selected. That's how a . jmp 0000 or . jmp 8000 is always handled by the rel8 code in the immediate assembler, and behaves as expected.
There is an unintended even more ingenious way that occurs in a different case: if . jmp near 8000 is entered, then the assembler's rel8 code runs first as before, but the alloweddist check will reject the modified rel8 encoding despite the all-zeroes rel value. The assembler goes on to encode the jump as an actual rel16 jump (E9h). But the flag and target variables are still set by the rejected rel8 handling, so everything works out as desired even though the assembler emitted the E9h jump.
The remaining changes concern building with different options, chiefly initiated by allowing the _SYMBOLIC option to build again.
- Use the SOURCEFILENAME define for disambiguating wlcalc and wllist symbols instead of __FILE__, as the latter may contain slashes.
- In run.asm add _LINK conditionals using wlcalc for adding two extern symbols.
- Move symbolasm_error equate for error into debug.asm, as NASM doesn't allow to have an equate refer to an extern symbol (slightly different variant of this error but also involves an equate, now I added a new test case in which an extern equate is defined as an equ of an extern label).
- Default to enable _DUALCODE for _SYMBOLIC _PM=0 build.
- In xxshared.asm avoid a line_out size calculation for _LINK_COMPAT as _LINK build cannot calculate it. (wlcalc could be used, but wouldn't be hardened to allow either a byte or a word operand for the result.)
- Add extern directives for _SYMBOLIC _PM build, _DX, and _EMS builds.
- Default to enable _SYMBOLASMDUALCODE option define. _PM _DEBUG _DEBUG_COND _SYMBOLIC build overflows first code section without it.
- Rename _SYMBOLASMDUALCODE to _SYMBOLSASMDUALCODE to reflect the filename symbols.asm more.
- Add extern directives for several more options.
symsnip
- In insert.asm stand-alone code, use addsection directive to avoid convlist.pl error for symbolic -f obj lDebug build.
- Use wlcalc for _LINK build of debugger with the _SECOND_SLICE or _BUFFER_86MM_SLICE options. The wlcalc uses are for shifting size symbols to obtain word sizes.
