Help needed with a coding problem in 8086

I am trying to implement this C/C++ function in assembler.

BYTE GetKey()

This function uses appropriate bios function calls.
I want the function to quit when the Escape key is pressed.
The function returns a character from the keyboard if there is one.
If there is not one it returns 0.

The function does not wait for a key press, it simply returns a
char if there is one.
Anyone help?

thanks,
Qas17uk

Comments

  • [code]
    MOV AH,1 ; get keyboard status
    INT 16H ; bios int
    JZ NOKEY ; ZF set if no key, AH=scan code, AL=character
    MOV AH,0 ; get character from keyboard buffer
    INT 16h ; returns, AH=scan code, AL=character
    JMP SHORT KBDBYE
    NOKEY: XOR AX,AX ;zero out AX
    KBDBYE:
    [/code][green]
    See Ralf Browns interrupt list for details.
    You debug & rework the code above to your liking.

    Note: function AH=1 does not flush the key board buffer of a key, but does return the key info
    See AH=10h & 11h for enhanced keyboards
    function AH=0 removes a key from the KBD buffer.

    I hope that helps somehow.
    Bitdog
    [green]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion