home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 8921 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  3.8 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!utcsri!bonnie.concordia.ca!hobbit.ireq.hydro.qc.ca!beaurega
  2. From: beaurega@ireq.hydro.qc.ca (Denis Beauregard)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Results of the smallest TSR contest
  5. Summary: the smallest _useful_ take 16 bytes
  6. Message-ID: <BtvM6J.70o@ireq.hydro.qc.ca>
  7. Date: 1 Sep 92 01:44:43 GMT
  8. Sender: news@ireq.hydro.qc.ca (Netnews Admin)
  9. Organization: Institut de recherche d'Hydro-Quebec, Varennes, Canada
  10. Lines: 93
  11.  
  12. Background
  13.  
  14. I proposed the contest after reading this :
  15.  
  16.  
  17. Gregory Humphreys :
  18.   There is NOTHING you can't do in C that you CAN in assembley.
  19.  
  20. Ralf Brown :
  21.   Hmm, I sense a challenge.  OK, how about a TSR that only takes 64 bytes when
  22.   resident?  Or a swapping spawn() that takes less than 300 bytes while the
  23.   child program executes?
  24.  
  25.  
  26. Then, I proposed the contest : the Smallest TSR Program
  27.  
  28. In the category : Assembly only (out of competition)
  29.   128 bytes for a program swapping keys of the keyboard (no example given)
  30.  
  31. In the category : HLL with almost no Assembly
  32.   Duncan Murdoch
  33.   160 bytes for a similar program (key swapper)
  34.  
  35. In the category : HLL with Assembly
  36.   Ross Ridge
  37.   64 bytes for a TSR counter
  38.  
  39. Note : I have no Borland compiler on hand.  But, statements like
  40. #define get_strategy() (_AX=0x5800, INT21(), _AX)
  41. looks like inline functions.  What is doing _AX=0x5800 ?  Compiling
  42. this into "mov ax,$5800" ?  If true, this is inline!
  43.  
  44.  
  45. I would say the winner is HLL with Assembly, but I would
  46. like to see the key swapper written with the same method.  
  47.  
  48.  
  49. My own entry : doing the key swapper in HLL + Inline.
  50. Let's presume I use the same loader as Ross' program.
  51. The result would give 48 bytes.  Compare with 160 bytes without assembly.
  52.  
  53. The program is (in assembly) :
  54.  
  55. swapkey:
  56.         cmp   ax,0x4F00 + K_ESC  3      'K_ESC = 01Bh = Esc key code
  57.         jne   t2                 2
  58.         mov   al,K_BS            2
  59.         jmp   short done         2  9
  60. t2:
  61.         cmp   ax,0x4F00 + 'X'    3
  62.         jne   t3                 2
  63.         mov   al,'Z'             2
  64.         jmp   short done         2 18
  65. t3:
  66.         cmp   ax,0x4F00 + K_BS   3      'K_BS = 008h = Backspace key code
  67.         jne   t4                 2
  68.         mov   al,K_ESC           2 25
  69.                                         'jmp not required here
  70. t4:
  71.         cmp   ax,0x4F00 + 'Z'    3
  72.         jne   done               2
  73.         mov   al,'X'             2 30
  74. done:
  75.         jmp   long old_vector    5 35
  76.         
  77. Counting 5 bytes for Memory Control Block header and using a
  78. MCB header contiguous to memory controlled, I need 40 bytes.
  79. 8 bytes are lost because of 8088 segments (could have X -> Y -> Z -> X)
  80. If swapping is with X <-> Y and A <-> B, then I need 4 bytes less,
  81. but this gives only 12 bytes wasted.  BUT, if I swap 3 keys, then
  82. the program is under 32 bytes!  
  83.  
  84. P.S.  This program has not been tested.  (I don't really need to
  85. swap keys on my PC!).
  86.  
  87. P.P.S.  In the category, a _truely_ useful TSR, I once wrote a
  88. program resetting the 80387 coprocessor after using a given
  89. interrupt (it was actually a bug in the BIOS, I think in a Jet 386
  90. card added to an IBM PC with a 286).  While I used the standard
  91. method of installing a TSR (i.e. keeping the PSP), I think the 
  92. useful part of the program installed inside an MCB header just needed
  93. 16 bytes.  i.e. a truely useful (without it, a program could not
  94. run) TSR within 16 bytes.
  95.  
  96. I think the program was something like this : FINIT, JMP OLD_INT
  97. short, but really appreciated by my colleague, and the original
  98. bug was really not obvious.
  99.  
  100. -- 
  101.   \_\    Denis Beauregard  *  internet:beaurega@ireq.hydro.qc.ca
  102.  /   \   Genealogiste officiel : Beauregard/Jarret/Jarest/Vincent
  103. J   __>  Un Quebec renouvele dans une Amerique renovee
  104. \_.-===                                                  Opinions ? Et pis non !
  105.