User Tools

Site Tools


blog:pushbx:2023:0424_mid_april_work

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

blog:pushbx:2023:0424_mid_april_work [2023-04-24 17:35:40 +0200 Apr Mon] (current)
ecm created
Line 1: Line 1:
 +====== Mid April work ======
 +
 +**2023-04-23**
 +
 +This week I did some work on ldosboot, the checksumming companion repo, and lDebug.
 +
 +
 +===== ldosboot: checkpl =====
 +
 +[[https://hg.pushbx.org/ecm/ldosboot/rev/e1cec700e163|The new checksumming stage]] is called checkpl. It is [[https://hg.pushbx.org/ecm/ldosboot/file/e1cec700e163/nullpl.asm|based on the earlier nullpl]], which would just pass along control to its payload. Unlike the prior checksumming implementation, this stage is loaded as a payload by iniload, and in turn passes control to its own payload. That means it needs to be able to handle device driver and application mode entries. In turn, it also works in those modes rather than only when bootloaded.
 +
 +Unlike the prior method, this checksums only part of its own payload as well as (for now) its own relocation and checksumming code. To allow debuggers to proceed past the checksumming, an int3 breakpoint is hardcoded behind the call instruction. There will probably be an option to checksum only part of the payload, without the checksumming code itself.
 +
 +The reason that not the entire payload is checksummed is to allow use of a FreeDOS kernel CONFIG block early in the payload. To this end, the first 256 bytes of the checkpl stage's payload are not included in the checksum.
 +
 +The checksum header format as well as the ''checksum'' program [[https://hg.pushbx.org/ecm/crc16-t/file/99649f7ba4e5|are both unchanged]] from the prior revision. The ''inicheck'' file which contains the assembly implementation of the checksumming [[https://hg.pushbx.org/ecm/crc16-t/rev/99649f7ba4e5|was modified slightly]] to accommodate that the image to sum does not start at the checksummer's code segment, and that the checksum header is most likely not addressed with that code segment either.
 +
 +For now the checksummer processes its image in 64 KiB chunks, so the ''di'' [[https://hg.pushbx.org/ecm/ldosboot/file/e1cec700e163/checkpl.asm#l367|input that indicates the segment of the checksum header]] needs to be calculated to match the 64 KiB chunk in which the header will be found. Likewise [[https://hg.pushbx.org/ecm/ldosboot/file/e1cec700e163/checkpl.asm#l642|the offset of the checksum field]] needs to be calculated relative to this chunk. To allow access from the checkpl's code segment, [[https://hg.pushbx.org/ecm/ldosboot/file/e1cec700e163/checkpl.asm#l646|a different label]] was added.
 +
 +
 +===== lDebug changes to section layouts =====
 +
 +These changes are optimisations intended to reduce memory use, or address things differently to reduce utilisation of a certain segment.
 +
 +The first is [[https://hg.pushbx.org/ecm/ldebug/rev/854efbf457bd|to discard all boot-loaded mode specific code]] when loading in application or device driver mode. To this end, the code in question (in ''boot.asm'') [[https://hg.pushbx.org/ecm/ldebug/rev/e4870fbda4b9|was moved to the end]] of the ''lDEBUG_CODE'' segment. This saves about 9 kB of resident memory use when not boot loaded.
 +
 +The second is [[https://hg.pushbx.org/ecm/ldebug/rev/5d0abf7d153f|to move a number of long help messages into the new "message segment"]]. For lDebugX [[https://hg.pushbx.org/ecm/ldebug/rev/feacaf56baaa#l3.1|an additional selector is allocated]] to address this segment. This moves about 22 kB out of the process/data/entry/stack segment, into the new segment.
 +
 +The third [[https://hg.pushbx.org/ecm/ldebug/rev/9c11a14596b2|is to discard]] the ''?BOOT'' online help page if not in boot loaded mode. Similarly to the code change, the message was moved to the end of the "message segment" first. The message data [[https://hg.pushbx.org/ecm/ldebug/rev/ab481f08e7f3|is overwritten with a shorter message]] that indicates the help page is not available, requiring no changes to the resident code. This saves more than 2 kB of resident memory use.
 +
 +
 +
 +===== An unrelated lDebug change =====
 +
 +[[https://hg.pushbx.org/ecm/ldebug/rev/f94205c75519|A bugfix]]: The QC command to quit a device driver mode debugger after its device is already installed would fail if the debugger's sub-MCB memory block was not at the end of the container MCB.
 +
 +
 +===== lDebug changes to the assembler/disassembler tables =====
 +
 +Most of these changes are to the ''mktables'' table generation program, with some changes to how the assembler and disassembler use these tables and very minor changes to the table source files.
 +
 +''mktables'' changes include:
 +
 +Switch [[https://hg.pushbx.org/ecm/ldebug/rev/194c0f3e4997|to specify a different table output filename]].
 +
 +Switches to limit the tables to certain machine levels, most importantly ''186'', ''286'', and ''386''.
 +
 +Unused operand lists (oplists) [[https://hg.pushbx.org/ecm/ldebug/rev/7cb66bb4fee8|can now be discarded]] by ''mktables'' rather than including them with merely a warning message.
 +
 +A new switch, ''nooffset'', allows [[https://hg.pushbx.org/ecm/ldebug/rev/f7a5355a5af5|to suppress the offset display comments]] in the oplist and mnemonic tables. This is intended to help compare the output of different runs. For now, however, the default remains to include the offsets.
 +
 +Most of the prior mechanisms to support re-ordering of oplist structures were thrown out. Instead, the assembler table and mnemonic table that are built internally by ''mktables'' now (crucially) refer to the ''kp->value'' values directly, which reference the original position of each oplist structure in the array. Next, the merging and required re-ordering is done. Then, the "final L" value is assigned in the new order, only accounting for oplists that are in use. When the internal tables are read back to create the output file, the "final L" value is read from the structure.
 +
 +The "final L" value is an index into the list of oplists, as used by the ''variant'' macro for the assembler and in the ''optypes'' disassembler table. The offsets are still calculated, but are used only for the offset display comments.
 +
 +Other changes include that assembling a lone ''fs'' or ''gs'' prefix [[https://hg.pushbx.org/ecm/ldebug/rev/b3ebc345b7ea|will now emit]] a ''[needs 386]'' message if the assembler machine is set up as below a 386. And the build option ''_DISASM_32BIT'' can be disabled [[https://hg.pushbx.org/ecm/ldebug/rev/4746acc9302b|to save a few bytes in the disassembler]] by dropping its support for 32-bit address size and operand size.
 +
 +All the other changes to the debugger's sources are about supporting the new different table formats. The ''_TABLENAME'' build option can be used to select a table filename other than the default ''debugtbl.inc''. The ''da23'' code will work correctly even if passed a zero-length table. The existence of the ''MN_BSWAP'', ''MN_O32'', and ''MN_GS'' defines is checked using ''%ifdef'' to make some code conditional on whether the table includes these mnemonics.
 +
 +{{tag>ldosboot ldebug}}
 +
 +
 +~~DISCUSSION~~
  
blog/pushbx/2023/0424_mid_april_work.txt ยท Last modified: 2023-04-24 17:35:40 +0200 Apr Mon by ecm