Let's be honest: In DOS, every byte actually matters. This is especially apparent when it comes to TSRs!
For those around during the era, what programming techniques/special assembler directives (creative uses of ORG?) did you use to code your TSRs to save space?
In particular, here's one I've been batting around: One technique that NASM suggests is to do the following:
I.e. use the setup code as the .bss. I'm not sure if this is possible using MASM- is it? Regardless, I think we could do even better! Unfortunately, due to this being a COM program, we lose 256 bytes to the PSP, and I'm pretty sure we don't get that back after making the TSR syscall. If we relocate the resident code to the start of the segment, all offsets are off by 0x100, unless we manually fix the offsets. I wonder if it's worth the effort to create a small relocator for the resident portion/whether someone has actually done it?
If so, I wonder: can it be done in both MASM/NASM?
For those around during the era, what programming techniques/special assembler directives (creative uses of ORG?) did you use to code your TSRs to save space?
In particular, here's one I've been batting around: One technique that NASM suggests is to do the following:
Code:
org 100h ; it's a .COM program
jmp setup ; setup code comes last
; the resident part of the TSR goes here
setup:
; now write the code that installs the TSR here
absolute setup
runtimevar1 resw 1
runtimevar2 resd 20
tsr_end:
I.e. use the setup code as the .bss. I'm not sure if this is possible using MASM- is it? Regardless, I think we could do even better! Unfortunately, due to this being a COM program, we lose 256 bytes to the PSP, and I'm pretty sure we don't get that back after making the TSR syscall. If we relocate the resident code to the start of the segment, all offsets are off by 0x100, unless we manually fix the offsets. I wonder if it's worth the effort to create a small relocator for the resident portion/whether someone has actually done it?
If so, I wonder: can it be done in both MASM/NASM?