User Tools

Site Tools


blog:pushbx:2023:0507_early_may_work_on_inicomp_ldosboot_ldebug_einsicht

Early May work on inicomp, ldosboot, lDebug, Einsicht

2023-05-07

The last day of April and first week of May several developments happened.

inicomp changes to use without iniload or MZ shim wrapper stage

The primary change in inicomp is the option _IMAGE_EXE_GET_COM_STACK which allows to set up a separate stack segment at the end of the process memory block. This is required for the intended functioning of the application (exe mode) entrypoint when the inicomp stage is directly loaded as a flat .COM style executable.

With a slight modification of their device mode entrypoints this allows to compress the dual-mode Logger executable using inicomp. However, the compression ratio of the full file (compressed payload plus depacker) is worse than UPX manages. The LZMA-lzip file is actually larger than the LZSA2 file, as the LZMA depacker is larger.

There is a problem: If the stack allocated to the application mode entrypoint is too small, the initial relocation could overlap and fail. This is unlikely, but could happen.

There is another change to inicomp, which is to drop a little code that is specific to boot loaded mode. This doesn't buy much space however.

ldosboot changes

The only change of the sources is an optimisation in fdkernpl to re-use part of the subsequent iteration code for the first iteration of the image relocation. This was tested using both a small (< 64 KiB) and a large image.

The other change is an update to the documentation to describe application mode and device mode entries. These have been used for the debugger for a long time now but weren't documented anywhere yet. This is still missing the fact that inicomp expects an auto stack for application mode, and that the subsequent stages can either pass along the auto stack (auto stack enabled) or set up their own output stack (auto stack disabled).

lDebug changes

The first change happened last Sunday for the most part: The _EXPRDUALCODE option allows to move most code from expr.asm into the second code segment. Several scriptlets were used to automate parts of these changes. (One of these failed to process labels that ended in a question mark, at first.) Most of them are documented in the changeset messages. About 5 kB of code can be moved this way.

As a part of this change, the section_of_function macro gained an optional parameter. This is intended to specify the base name if the label before the macro call is a local label.

Several uses of dispatch tables or indirect calls into expr.asm code in a few other files were adjusted.

The bits of lDEBUG_CODE contents in init.asm were moved into debug.asm because boot.asm needs to come after all non-boot lDEBUG_CODE bits, but init.asm now needs to come after boot.asm as init.asm defines the relocation patch tables, some of which now need to include nearcall uses in boot.asm. (The init.asm definition of the tables had the foresight of using %unmacro on the call macros, so that such an error is caught at build time instead of silently ignoring the latter relocations.)

A test from test.py was fixed to work with the getinput optimisations. This is the first test breakage in a while, though we haven't added any tests in a while either.

Two build options were added to address feature requests for FreeDOS Debug/X from the FreeDOS sourceforge bug tracker. One of those adds a linebreak before every R command dump. The other changes the style of the symbolic flags display from the Debug-style state abbreviations to just "x1" or "x0", respectively "x_", where the "x" is a letter indicating which flag is meant. The latter build option is disabled by default. Both build options lead to run time options being added, which still have to be enabled at run time.

A recent change is to add the RC.ABORT command. This is useful in one particular case: The command-line buffer includes a Y command to run a script file, eg /cycfg.sld. Then the script file wants to re-define the contents of the RC buffer – but it cannot, because the RC buffer is still executing. The new command can be used to abort execution of the RC buffer, discarding all yet unused commands from it (if any). Then the Script for lDebug file can use RC.REPLACE to change the RC buffer contents. This use case came up during debugging of the Einsicht additions. An equivalent for the RE buffer doesn't make any sense, because the RE buffer is the highest priority input source, so if you were to abort it you wouldn't be able to chain any otherwise impossible RE.REPLACE commands. (The way to abort the RE buffer processing from within the RE buffer itself is simply goto :EOF.) (Arguably there could be an RC./RE. command to both abort and replace the corresponding buffer contents.)

The final changes are about fixing and supporting the exception areas. The fix was found during checking that the areas were initialised properly. Turned out the truncated lDEBUG_CODE section's length was written in paragraphs, when it should be written as a linear address value (in bytes).

Another change was to fix the HH indirection access area to point to lDEBUG_CODE2 if the _EXPRDUALCODE option is in effect. This required adding another areas sub structure.

However, this was not satisfying because the areas function definitions don't know how to handle cross-section relocated nearcall calls to their functions. So to "fix" the area for HH indirection, the call to readmem now indirects through a dualcall to a small relocator. (This indirection is not unlike what _DUALCODENEARDUAL does for all nearcall calls when _PM=0.) The relocator gets its own area in the lDEBUG_CODE (first code section) areas.

Einsicht (and Insight) changes

The Einsicht changes are mostly about getting the data dump to work with the remote lDebug. The original Insight data dump will leave the dump empty. If connected, an lDebug command is sent to dump the affected area. It uses a LINES length to the D command in order to allow Insight-style dumps that wrap around from 0FFFFh to 0000h. Modification of the data, either as digits or as text, is also implemented, though this is considered naive.

A lot of commands are sent to lDebug the way this is implemented for now. Two killer features are still missing: A new lDebug command prefix to avoid a command being entered into the lDebug command history, and Einsicht changes to suppress the prompt and output of commands sent by Einsicht. If these were added, the terminal window view of lDebug would be a lot more usable in Einsicht.

Einsicht will also detect the "KEEP" prompt from lDebug now and reply to it automatically. A similar detection is done to determine when lDebug is waiting at a normal command prompt, rather than an assembly prompt, interactive E prompt, paging prompt, or busy writing output. The function einsicht_send_command will wait a bit for lDebug to prompt; if it doesn't then the command is not sent (and one time per Einsicht key input a beep is emited).

A small fix is to reset the rpos variable in the init_terminal_size function. This means if the first byte written to the terminal is not a blank nor linebreak, then it won't be wrongly displayed at the last prompt position when exiting the terminal window.

The only change that also applies to Insight is that menues can be closed using Alt+X now.

You could leave a comment if you were logged in.
blog/pushbx/2023/0507_early_may_work_on_inicomp_ldosboot_ldebug_einsicht.txt · Last modified: 2023-05-07 16:59:50 +0200 May Sun by ecm