BIOS Programming

Getting User Keyboard Input

Generally having user interaction make a program more useful than a program that just displays static data. To get user input we will be using a different interrupt than 10h, this time we will be using 16h.

The way subroutine `0` works, is that we store 0 into `ah`, and then we call int 16h. The system will wait for a key press and when it receives a key press it will set a value to `ah` and a value to `al`. These values can be found on the key codes table.

Let's look at some example code:

                    
    mov ah, 0x0
    int 16h
    cmp ah, 0x1c ;code for enter key
    je keyIsEnter
    cmp ah, 0x01 ;code for esc key
    je keyIsEsc
keyIsEnter:
    ;enter logic here
keyIsEsc:
    ;escape logic here