Article View: comp.os.msdos.programmer
Article #1166Results of the smallest TSR contest
From: Denis Beauregard
Date: Tue, 01 Sep 1992 01:44
Date: Tue, 01 Sep 1992 01:44
93 lines
3982 bytes
3982 bytes
Background
I proposed the contest after reading this :
Gregory Humphreys :
There is NOTHING you can't do in C that you CAN in assembley.
Ralf Brown :
Hmm, I sense a challenge. OK, how about a TSR that only takes 64 bytes when
resident? Or a swapping spawn() that takes less than 300 bytes while the
child program executes?
Then, I proposed the contest : the Smallest TSR Program
In the category : Assembly only (out of competition)
128 bytes for a program swapping keys of the keyboard (no example given)
In the category : HLL with almost no Assembly
Duncan Murdoch
160 bytes for a similar program (key swapper)
In the category : HLL with Assembly
Ross Ridge
64 bytes for a TSR counter
Note : I have no Borland compiler on hand. But, statements like
#define get_strategy() (_AX=0x5800, INT21(), _AX)
looks like inline functions. What is doing _AX=0x5800 ? Compiling
this into "mov ax,$5800" ? If true, this is inline!
I would say the winner is HLL with Assembly, but I would
like to see the key swapper written with the same method.
My own entry : doing the key swapper in HLL + Inline.
Let's presume I use the same loader as Ross' program.
The result would give 48 bytes. Compare with 160 bytes without assembly.
The program is (in assembly) :
swapkey:
cmp ax,0x4F00 + K_ESC 3 'K_ESC = 01Bh = Esc key code
jne t2 2
mov al,K_BS 2
jmp short done 2 9
t2:
cmp ax,0x4F00 + 'X' 3
jne t3 2
mov al,'Z' 2
jmp short done 2 18
t3:
cmp ax,0x4F00 + K_BS 3 'K_BS = 008h = Backspace key code
jne t4 2
mov al,K_ESC 2 25
'jmp not required here
t4:
cmp ax,0x4F00 + 'Z' 3
jne done 2
mov al,'X' 2 30
done:
jmp long old_vector 5 35
Counting 5 bytes for Memory Control Block header and using a
MCB header contiguous to memory controlled, I need 40 bytes.
8 bytes are lost because of 8088 segments (could have X -> Y -> Z -> X)
If swapping is with X <-> Y and A <-> B, then I need 4 bytes less,
but this gives only 12 bytes wasted. BUT, if I swap 3 keys, then
the program is under 32 bytes!
P.S. This program has not been tested. (I don't really need to
swap keys on my PC!).
P.P.S. In the category, a _truely_ useful TSR, I once wrote a
program resetting the 80387 coprocessor after using a given
interrupt (it was actually a bug in the BIOS, I think in a Jet 386
card added to an IBM PC with a 286). While I used the standard
method of installing a TSR (i.e. keeping the PSP), I think the
useful part of the program installed inside an MCB header just needed
16 bytes. i.e. a truely useful (without it, a program could not
run) TSR within 16 bytes.
I think the program was something like this : FINIT, JMP OLD_INT
short, but really appreciated by my colleague, and the original
bug was really not obvious.
--
\_\ Denis Beauregard * internet:beaurega@ireq.hydro.qc.ca
/ \ Genealogiste officiel : Beauregard/Jarret/Jarest/Vincent
J __> Un Quebec renouvele dans une Amerique renovee
\_.-=== Opinions ? Et pis non !
Technical Details
Message-ID:
<BtvM6J.70o@ireq.hydro.qc.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!utcsri!bonnie.concordia.ca!hobbit.ireq.hydro.qc.ca!beauregaShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!utcsri!bonnie.concordia.ca!hobbit.ireq.hydro.qc.ca!beaurega From: beaurega@ireq.hydro.qc.ca (Denis Beauregard) Newsgroups: comp.os.msdos.programmer Subject: Results of the smallest TSR contest Summary: the smallest _useful_ take 16 bytes Message-ID: <BtvM6J.70o@ireq.hydro.qc.ca> Date: 1 Sep 92 01:44:43 GMT Sender: news@ireq.hydro.qc.ca (Netnews Admin) Organization: Institut de recherche d'Hydro-Quebec, Varennes, Canada Lines: 93