BIOS Programming

Setting the Cursor Position

Up to this point we have been able to show text on the screen whereever the current cursor is. Let's enhance this so that we can move the cursor wherever we want it to be on the screen.

To do this we will be using subroutine `2` of the 10h interrupt. In addition to using the `ax` register we will also be using the `dx` register. `dh` will be used to set which row we want the cursor to move to. `dl` will be used to set the column we want to the cursor to move to. Notice, both `dh` and `dl` are zero based, meaning that zero is the first spot on the screen.

Let's look at some example code:

                    
    mov ah, 0x2
    mov dh, 0x3 ; "fourth row" (zero based)
    mov dl, 0x2 ; "third column" (zero based)
    int 10h
    mov dx, 0x0302 ; Identical to the above
    int 10h