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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!rutgers!rochester!cantaloupe.srv.cs.cmu.edu!ralf
  2. From: Ralf.Brown@B.GP.CS.CMU.EDU
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Re: Results of the smallest TSR contest
  5. Message-ID: <2aa36355@ralf>
  6. Date: 1 Sep 92 12:34:29 GMT
  7. Sender: news@cs.cmu.edu (Usenet News System)
  8. Organization: Carnegie Mellon University School of Computer Science
  9. Lines: 80
  10. In-Reply-To: <BtvM6J.70o@ireq.hydro.qc.ca>
  11. Originator: ralf@B.GP.CS.CMU.EDU
  12. Nntp-Posting-Host: b.gp.cs.cmu.edu
  13.  
  14. In article <BtvM6J.70o@ireq.hydro.qc.ca>, beaurega@ireq.hydro.qc.ca (Denis Beauregard) wrote:
  15. }Then, I proposed the contest : the Smallest TSR Program
  16. }In the category : Assembly only (out of competition)
  17. }  128 bytes for a program swapping keys of the keyboard (no example given)
  18.  
  19. See PD1:<MSDOS.KEYBOARD>RBKEYSWP.ZIP on SIMTEL20.  Includes full source.
  20. It's actually 53 bytes of resident code, which requires a 64-byte UMB or
  21. 128 bytes in low memory (64 bytes of PSP).  Of those 53 bytes, 16 bytes are
  22. overhead to make sure that the right control key is ignored and only the
  23. left one is remapped.
  24.  
  25. }In the category : HLL with almost no Assembly
  26. }  Duncan Murdoch
  27. }  160 bytes for a similar program (key swapper)
  28. }In the category : HLL with Assembly
  29. }  Ross Ridge
  30. }  64 bytes for a TSR counter
  31.  
  32. I didn't see this one.  That must be in a UMB, as DOS won't let a program go
  33. TSR with less than 96 bytes.
  34.  
  35. }My own entry : doing the key swapper in HLL + Inline.
  36. }Let's presume I use the same loader as Ross' program.
  37. }The result would give 48 bytes.  Compare with 160 bytes without assembly.
  38. }The program is (in assembly) :
  39. }swapkey:
  40. }        cmp   ax,0x4F00 + K_ESC  3      'K_ESC = 01Bh = Esc key code
  41.  
  42. K_ESC should be 01h, etc.  While this program might actually work on
  43. your system after fixing the scan codes, it is not correct.  When you
  44. press and release Esc, your BIOS (and anybody else hooked into INT
  45. 15/4F) will see you press BackSpace and release Esc....
  46.  
  47. }Counting 5 bytes for Memory Control Block header and using a
  48. }MCB header contiguous to memory controlled, I need 40 bytes.
  49.  
  50. That won't necessarily work if you want to load into an XMS UMB, since
  51. different XMS implementations handle them differently.    Also, DOS 4+
  52. use the last 8 bytes of the MCB for a program name, so overwriting that
  53. part with code may confuse many memory mappers.
  54.  
  55. Here's the RBkeyswap resident code, stripped of the right-control checking.
  56. 37 bytes of code.
  57.  
  58. int15_handler:
  59.        cmp    ah,4Fh            ; scan code translation?
  60.        jne    not_ours        ; if not, chain immediately
  61.        shl    al,1            ; move break bit into CF
  62.        pushf                ;   and remember it for later
  63.        cmp    al,1Dh*2        ; ctrl?
  64.        je    ctrl_or_capslock
  65.        cmp    al,3Ah*2        ; capslock?
  66.        je    ctrl_or_capslock
  67.        cmp    al,01h*2        ; ESC?
  68.        je    esc_or_tilde
  69.        cmp    al,29h*2        ; backquote/tilde key?
  70.        jne    int15_no_xlat
  71. esc_or_tilde:
  72.        xor    al,0Fh*2        ; (AL xor 0F) xor 27 == (AL xor 28h)
  73.                     ; 01h -> 29h, 29h -> 01h
  74.                     ; thus esc and tilde swapped
  75. ctrl_or_capslock:
  76.        xor    al,27h*2        ; 1Dh -> 3Ah, 3Ah -> 1Dh
  77.                     ; thus left-ctrl and capslock swapped
  78. int15_no_xlat:
  79.        popf                ; retrieve break bit in CF
  80.        rcr    al,1            ;   and add to translated scan code
  81.        stc                ; use the scan code
  82. not_ours:
  83.        db    0EAh            ; FAR JMP chain to previous handler
  84. old_int15 dd    ?
  85.  
  86. -- 
  87. Internet: RALF+@CS.CMU.EDU   |The University would disclaim this if it knew...
  88. FIDO: Ralf Brown 1:129/26.1  |
  89. BIT: RALF%CS.CMU.EDU@CARNEGIE|"Success has a simple formula: do your best,
  90. AT&Tnet: (412)268-3053 school| and people may like it."   -- Sam Ewing
  91.