[net.micro.pc] Help on MASM/DOS-interrupt-handler

herman@ti-csl (04/11/86)

Off-hand I would say you're destroying the information that the
keyboard I/O function returns for AH=1.  The Z-flag normally contains
info on character availability (ZF=1 -> unavailable).
An IRET will not preserve the current status of the Z-flag.  In
order to do that, you would normally do a RET 2, i.e. pop the flag
information, without actually restoring the flag.

	. . . . . . . . . .

	cmp     ah,dos_look_keyboard ; check for LOOK function...
	je      do_translate         ;   if so, prepare to translate
        cmp     ah,dos_read_keyboard ; check for READ function...
        jne     no_translate         ;   if not, just jump to old interrupt

do_translate:
        assume  ds:nothing
        pushf                   ; simulate normal Keyboard Interrupt
        call    old_keyboard_io

	pushf			; save clobberable stuff
        cmp     al,00h          ; do we have a "special" keypress?
        je      return          ; if yes, don't screw around with it
        push    bx
        mov     bx,offset char_map_tab ; set up for character translate
        xlat    char_map_tab    ; translate character
        xchg    ah,al           ; swap character and scan code
        mov     bx,offset scan_map_tab ; set up for scan code translate
        xlat    scan_map_tab    ; translate scan code
        xchg    ah,al           ; unswap character and scan code
        pop     bx              ; restore clobbered stuff

return:
	popf			; restore return flags
        ret	2		; return to caller

no_translate:
        assume  ds:nothing
        jmp     old_keyboard_io ; do normal interrupt, let it return to caller

	. . . . . . . . .

This code is still not totally correct, since it always passes the flags
back to the caller, rather than only in case AH=1, but the required changes
should be trivial.

================================================================
*hardcopy*		*electr{onic, ic}*
Herman Schuurman	ARPA:  herman%TI-CSL@CSNET-RELAY.ARPA
POB 225474 M/S 238	CSNET: herman@TI-CSL
Texas Instruments Inc.	USENET: {ut-sally,convex!smu,texsun,rice}!ti-csl!herman
Dallas, Texas		VOICE: (214) 995-0845
75265