News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Flushing Keyboard Buffer

Started by popcalent, February 09, 2024, 07:53:00 AM

Previous topic - Next topic

popcalent

I'm trying to flush the keyboard buffer, but I'm not succeeding. My program displays a message for the user to read, and the user has to press space for the program to erase the message and proceed. The problem is that if the user presses space before the message is displayed, the message will show for a fraction of a second, and the program will erase it and proceed. I've been trying INT 16h, and MOV IN, 60h, and no success so far... Help, please!

        FLUSH_KB_BUFFER:
                MOV     AH, 1h  ;CHECK IF KEY IS AVAILABLE
                INT     16h
                JZ      PRESS_SPACE_
                MOV     AH, 0h  ;READ PRESSED KEY
                INT     16h
                JMP     FLUSH_KB_BUFFER

        PRESS_SPACE_:
                MOV     AH, 0h
                INT     16h
                CMP     AH, KB_SPACE
                JNE     PRESS_SPACE_