User Tools

Site Tools


blog:pushbx:2025:0601_late_may_work

Late May work

2025-06-01

Little got done this week.

lDebug

Add opt2_dpminohlt and rename nohlt to opt1_86mnohlt. The latter is used only in Real/Virtual 86 Mode now, whereas the former is used only in Protected Mode.

The opt2_dpminohlt replaces an internal flag (dpminohlt) in DIF1 that didn't provide any way to clear it without hacking the DIF1 value in the debugger's memory.

The second changeset updates the help pages quoted in the manual.

The third changeset updates the news-r10 section with the flag changes and the recently added S MCB types.

lDOS boot

All changes concern testboot, the test boot sector that displays all register values, the interrupt vectors 00h to 1Fh, and the memory of the sector itself.

The major change is introducing "method 2" for the register/stack table. This packs each table item into a single 16 bit entry, split into three bit fields as 6:5:5, with the highest 6 bits for the stack offset (or table marker: -1 for EOL, -2 for end of table), and the lowest and middle 5 bits for the two "letters".

It turns out that the given data actually only needs to encode decits 0-9, hexits A-F, CR, LF, or the letters I, L, P, S, or X. It just so happens that the non-hexit letters plus the two linebreak codepoints sum to 7 total, which matches the size of the gap between '9' and 'A'. ('I' could be encoded after the hexits as well however, so there'd be space for another high letter.)

Except for the high markers, all stack offsets are even, so a bit could be saved by encoding half the offset. However, this wouldn't save anything in the current table format and would cost at least 2 bytes of code space to add the table value to itself (shift left by 1 bit).

The table items and the mmacro magic to encode them have to use C-style backquote string literals in order to encode CR and LF as preprocessor-supported strings. These were introduced with NASM v2.03 so earlier versions certainly won't be able to assemble these source texts.

(Trying to use %strcat %%foo "ILPSX", 13, 10 doesn't recognise the numeric parameters as codepoints for the string. Similary, %substr will always parse numeric parameters as offsets and lengths, not part of the string.)

There are some more changes:

  • Use table entry with offset as -2 as a method 2 "end of table" marker, saving 2 bytes of code space.
  • Use a function that dispatches to either displaying AX in hexadecimal (4 hexits) or AL (2 hexits), based on the Carry Flag input. Saves a few bytes as there are two spots where the code would dispatch to calling either of the two functions. (These spots are about displaying the IVT dump or the memory dump in function dump.)
  • Loop back to dump instead of calling it twice, also saving a few bytes. And remove the forgotten retn instruction after the loop optimisation.

Lesson: There's still ways to optimise code for size, even after already writing it with size in mind. On the other hand, with every optimisation that we add there's less potential ones left available.

You could leave a comment if you were logged in.
blog/pushbx/2025/0601_late_may_work.txt · Last modified: 2025-06-01 17:51:37 +0200 Jun Sun by ecm