A few additions to my prior mail:

On at 2023-05-01 13:04 +0200, C. Masloch wrote:
On at 2023-04-28 13:51 -0400, jer...@shidel.net wrote:
Hi All,

Logger is coming along great and I’m currently working on the final ALPHA-8 version. Once that is done, it will be time for a BETA or two. Then finally version 1.0.

Your IISP headers could store the required retf at a place other than after the header. This would save the short jump that you use to skip the retf. If you put the int 2Dh handler right after the resident device strategy handler, you could re-use the strategy handler's retf for the int 2Dh IISP header. Likewise the int 10h IISP header if it is close enough.

In my IISP header macro, iispentry [1], I can pass a label to use for the retf in one of the parameters. Also, it now by default aligns the IISP header to a word-boundary to slightly speed up accesses of the ieNext pointer.

It is good that your ieEntry jump already is the expected 10EBh, a jump to what I call ieStart. This is required for fully standard IISP headers, and Ralf Brown's programs expect this exact value there.

Other than that I didn't look at all your code yet for more optimisations.


[1]: https://hg.pushbx.org/ecm/ldebug/file/ab7d7f8b72d5/source/AMIS.MAC#l44

You can use a "jmp strict short" instruction in NASM to make sure that a short jump is assembled, and an error raised otherwise.

Here's the results of building my compressed dual-mode Logger executable, compressed using LZIP (high ratio, slow) and LZSA2 (faster):

This wasn't very readable so I will list the commands separately:

This is the LZIP compression command:

logger/BIN$ lzip -9vvfkc LOGGER.COM > logger.lz
LOGGER.COM:  1.650:1, 60.62% ratio, 39.38% saved, 9240 in, 5601 out.


This is the assembler command to build the inicomp stage:

logger/BIN$ nasm ../../inicomp/inicomp.asm -I ../../lmacros/ -I ../../inicomp/ -D_LZD -o loggerlz.com -D_PAYLOAD_FILE="'logger.lz'" -D_IMAGE_EXE=1 -D_IMAGE_EXE_AUTO_STACK=0 -D_DEVICE=1 -D_DEVICE_ZERO_ENTRYPOINT=1 -D_DEVICE_ATTRIBUTE=8000h -D_DEVICE_NAME="'LOGGERxx'" -D_IMAGE_EXE_CS=-16 -D_IMAGE_EXE_IP=256 -D_IMAGE_EXE_GET_COM_STACK -D_BOOTLDR=0 -D_ALLOW_OVERLAPPING=0
../../inicomp/lzd.asm:698: warning: localvariables has 14688 bytes [-w+user]
../../inicomp/inicomp.asm:1320: warning: inilz: 2992 bytes used for depacker [-w+user]


The -I switches above are needed so that NASM finds the include files. The lmacros and inicomp repo are both available from my hg repositories [1].

The -D_LZD switch tells inicomp what depacker to use.

-o specifies the output filename.

-D_PAYLOAD_FILE= specifies the payload file, and must be passed twice quoted from bash to NASM so that NASM ends up with a quoted string define.

-D_IMAGE_EXE enables the exe mode handling. Likewise, -D_DEVICE enables the device mode handling.

-D_IMAGE_EXE_AUTO_STACK disables passthrough of the depacker's stack. Instead, the ss:sp is set up as -16:0FFFEh from the program image address. That is, ss = PSP and sp = 0FFFEh.

-D_DEVICE_ZERO_ENTRYPOINT enables the jump within the device header, required for flat .COM style dual-mode executables.

-D_DEVICE_ATTRIBUTE and -D_DEVICE_NAME should be set up to match the compressed device driver header's.

-D_IMAGE_EXE_CS and -D_IMAGE_EXE_IP set up the initial cs:ip as -16:256, matching the normal flat .COM style entry.

-D_IMAGE_EXE_GET_COM_STACK is required to set up the expected stack for the depacker. It uses ss as the upper limit of memory available to it for depacking.

-D_BOOTLDR=0 and -D_ALLOW_OVERLAPPING=0 are some small optimisations.


This is the LZSA2 compression command:

logger/BIN$ lzsa -c -f2 --prefer-ratio -v LOGGER.COM logger.sa2
Compressed 'LOGGER.COM' in 0.072056 seconds, 0.12 Mb/s, 1141 tokens (8.09816 bytes/token), 9240 into 6050 bytes ==> 65.4762 %
Compared 'logger.sa2' in 3.9e-05 seconds, 225.947 Mb/s


Finally, the assembler command to build the LZSA2-packed executable. This is the same as above but with -D_LZSA2 and the different output and payload filenames.

logger/BIN$ nasm ../../inicomp/inicomp.asm -I ../../lmacros/ -I ../../inicomp/ -D_LZSA2 -o loggersa.com -D_PAYLOAD_FILE="'logger.sa2'" -D_IMAGE_EXE=1 -D_IMAGE_EXE_AUTO_STACK=0 -D_DEVICE=1 -D_DEVICE_ZERO_ENTRYPOINT=1 -D_DEVICE_ATTRIBUTE=8000h -D_DEVICE_NAME="'LOGGERxx'" -D_IMAGE_EXE_CS=-16 -D_IMAGE_EXE_IP=256 -D_IMAGE_EXE_GET_COM_STACK -D_BOOTLDR=0 -D_ALLOW_OVERLAPPING=0 ../../inicomp/inicomp.asm:1320: warning: inilzsa2: 1392 bytes used for depacker [-w+user]


This is the resulting files:

logger/BIN$ ls -lgG
total 48
-rw-r--r-- 1 9240 May  1 11:10 LOGGER.COM
-rw-r--r-- 1 5601 May  1 12:21 logger.lz
-rw-r--r-- 1 8608 May  1 12:21 loggerlz.com
-rw-r--r-- 1 6050 May  1 12:21 logger.sa2
-rw-r--r-- 1 7456 May  1 12:21 loggersa.com
logger/BIN$


Regards,
ecm


[1]: https://hg.pushbx.org/ecm/


_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to