Category : Files from Magazines
Archive   : NEWKEYS2.ZIP
Filename : NEWKEYS.ASM

 
Output of file : NEWKEYS.ASM contained in archive : NEWKEYS2.ZIP
;
; NEWKEYS.ASM -- Add 101-key support to the "standard" bios interrupt
; for programs that don't know about the "extended" calls.
;
; From PC-Magazine Volume 6, No. 13 July 1987, "PC Tutor" Pg. 479
; Copyright (C) 1987, 1988, Ziff Davis Communications. All Rights Reserved.
;
; Author: Charles Petzold, PC Magazine
; Revised by: Tim Farley, 1/5/89 Added additional comments.
; Tim Farley, 5/16/89 Modified handling of E0h so as to not
; strip ASCII "alpha" character typed
; at the keyboard using Alt-keypad.
; Tim Farley, 8/1/89 Released as NEWKEYS2.
;
; Instructions: Assemble this using the standard sequence:
; MASM NEWKEYS;
; LINK NEWKEYS;
; EXE2BIN NEWKEYS.EXE NEWKEYS.COM
; DEL NEWKEYS.OBJ
; DEL NEWKEYS.EXE
;
; I have tested that this will assemble with MASM 4.0 and TASM 1.0.
;
; Load this in your AUTOEXEC.BAT. Load it BEFORE any other utilities,
; especially TSR's, that access the keyboard. In particular, it must
; be loaded before most versions of PC Magazine's KEY-FAKE.COM.
;
; In utilities that let you install specific scan codes, you can use
; the new ones supported by the extended 101-key keyboards, such as
; F11, F12, Alt-ESCape, and others. See NEWKEYS.DOC for info.
;
CODE SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:CODE, DS:CODE, ES:CODE
ORG 100H ; Assemble to a COM file

NEWKEYS:
JMP SHORT INIT
;
OLDINT DD 0 ; Save existing INT 16 handler
; here, so we can jump to it.
;
; Our handler for INTerrupt 16 is here:
;
NEWINT: CMP AH,00 ; Is it Standard Read?
JZ SHORT READ ; Yes, let's intercept it.
CMP AH,01 ; No, Is it Standard Status?
JZ SHORT STATUS ; Yes, let's intercept it.
JMP DWORD PTR [CS:OLDINT] ; No, execute the Old Code then.
;
; Handle function 0, READ CHAR
;
READ: MOV AH,10H ; Change to Extended Read.
PUSHF ; Simulate an Interrupt Call.
CALL DWORD PTR [CS:OLDINT] ; Call the Old Code.
CALL FIXUP ; Fix it
IRET ; And Return.
;
; Handle function 1, READ STATUS
;
STATUS: MOV AH,11H ; Change to Extended Status.
PUSHF ; Simulate an Interrupt Call.
CALL DWORD PTR [CS:OLDINT] ; Call the Old Code.
JZ SHORT S_RET ; Exit If no key!
CALL FIXUP ; Fix it
S_RET: RETF 2 ; And Return.

;
; Exit routine for our remapped functions
; Must handle unusual replacement of 'E0' where '0' should be on
; extended key returns.
;
FIXUP: CMP AL,0E0H ; Extended Zero Code?
JNZ SHORT F_RET2 ; No, Then Return from Interrupt.
CMP AH,00 ; Is scan code 0, meaning (TF)
JZ SHORT F_RET1 ; user hit ALT-2-2-4? (TF)
SUB AL,AL ; Yes, Zero AL.
F_RET1: CMP AL,01 ; Force Non-Zero Return (TF)
F_RET2: RET ; Return

;
; Init routine. Simply installs our handler (above) and does an INT 27h
; to make this program remain resident
;
INIT: MOV AX,3516H ; Get OLD INT 16h Vector.
INT 21H ; DOS Function.
MOV WORD PTR [OLDINT],BX ; Save Offset.
MOV WORD PTR [OLDINT+2],ES ; Save Segment.
MOV DX,OFFSET NEWINT ; Load our INT 16h Offset
MOV AX,2516H ; Set NEW INT 16h Vector.
INT 21H ; DOS Function.
MOV DX,OFFSET INIT ; Point to the end of our code.
INT 27H ; Terminate & Stay Resident.
;
DB '(c) 1988 Ziff Communications Co.'
DB ' - by Charles Petzold'
;
CODE ENDS
END NEWKEYS


  3 Responses to “Category : Files from Magazines
Archive   : NEWKEYS2.ZIP
Filename : NEWKEYS.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/