🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1213

Re: Results of the smallest TSR contest

#1213
From: Ralf.Brown
Date: Tue, 01 Sep 1992 12:34
80 lines
3725 bytes
In article <BtvM6J.70o@ireq.hydro.qc.ca>, beaurega@ireq.hydro.qc.ca (Denis Beauregard) wrote:
}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)

See PD1:<MSDOS.KEYBOARD>RBKEYSWP.ZIP on SIMTEL20.  Includes full source.
It's actually 53 bytes of resident code, which requires a 64-byte UMB or
128 bytes in low memory (64 bytes of PSP).  Of those 53 bytes, 16 bytes are
overhead to make sure that the right control key is ignored and only the
left one is remapped.

}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

I didn't see this one.  That must be in a UMB, as DOS won't let a program go
TSR with less than 96 bytes.

}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

K_ESC should be 01h, etc.  While this program might actually work on
your system after fixing the scan codes, it is not correct.  When you
press and release Esc, your BIOS (and anybody else hooked into INT
15/4F) will see you press BackSpace and release Esc....

}Counting 5 bytes for Memory Control Block header and using a
}MCB header contiguous to memory controlled, I need 40 bytes.

That won't necessarily work if you want to load into an XMS UMB, since
different XMS implementations handle them differently.	Also, DOS 4+
use the last 8 bytes of the MCB for a program name, so overwriting that
part with code may confuse many memory mappers.

Here's the RBkeyswap resident code, stripped of the right-control checking.
37 bytes of code.

int15_handler:
       cmp	ah,4Fh			; scan code translation?
       jne	not_ours		; if not, chain immediately
       shl	al,1			; move break bit into CF
       pushf				;   and remember it for later
       cmp	al,1Dh*2		; ctrl?
       je	ctrl_or_capslock
       cmp	al,3Ah*2		; capslock?
       je	ctrl_or_capslock
       cmp	al,01h*2		; ESC?
       je	esc_or_tilde
       cmp	al,29h*2		; backquote/tilde key?
       jne	int15_no_xlat
esc_or_tilde:
       xor	al,0Fh*2		; (AL xor 0F) xor 27 == (AL xor 28h)
					; 01h -> 29h, 29h -> 01h
					; thus esc and tilde swapped
ctrl_or_capslock:
       xor	al,27h*2		; 1Dh -> 3Ah, 3Ah -> 1Dh
					; thus left-ctrl and capslock swapped
int15_no_xlat:
       popf				; retrieve break bit in CF
       rcr	al,1			;   and add to translated scan code
       stc				; use the scan code
not_ours:
       db	0EAh			; FAR JMP chain to previous handler
old_int15 dd	?

-- 
Internet: RALF+@CS.CMU.EDU   |The University would disclaim this if it knew...
FIDO: Ralf Brown 1:129/26.1  |
BIT: RALF%CS.CMU.EDU@CARNEGIE|"Success has a simple formula: do your best,
AT&Tnet: (412)268-3053 school| and people may like it."   -- Sam Ewing
Technical Details
Message-ID: <2aa36355@ralf>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!rutgers!rochester!cantaloupe.srv.cs.cmu.edu!ralf

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!rutgers!rochester!cantaloupe.srv.cs.cmu.edu!ralf
From: Ralf.Brown@B.GP.CS.CMU.EDU
Newsgroups: comp.os.msdos.programmer
Subject: Re: Results of the smallest TSR contest
Message-ID: <2aa36355@ralf>
Date: 1 Sep 92 12:34:29 GMT
Sender: news@cs.cmu.edu (Usenet News System)
Organization: Carnegie Mellon University School of Computer Science
Lines: 80
In-Reply-To: <BtvM6J.70o@ireq.hydro.qc.ca>
Originator: ralf@B.GP.CS.CMU.EDU
Nntp-Posting-Host: b.gp.cs.cmu.edu