Using the BIOS and DOS


The INT command

When the 8086 was designed, the designers created a structure which allows programmers to access ready-built routines built into the computer and operating system. The INT instruction is used to access these routines. It works like the CALL instruction, except instead of a procedure name, it uses a number between 0 and FFxH to specify the routine.

For example, at the end of the previous example programs, there was a INT 20xH instruction. This calls a procedure in DOS which terminates the program and removes it from memory.

I have compiled a list of all the procedures which can be called using interrupts (up to DOS 3.3 anyway). Click here for it in HTML format, or here for plain text format.

Calling DOS

DOS has a huge collection of routines available to the assembly programmer. There are routines for displaying text to the screen, allowing the user to enter data, and for accessing files. Nearly all DOS functions are called using interrupt number 21xH. To specify exactly which function is called, the function number must be stored in AH. Other data required by the routine must be stored in the other registers.

As an example, we'll look at DOS function 9, which displays some text to the screen. This function requires that the address of the data is stored in the DX register. (The DS register must also be set, but in these simple programs it will always be set correctly anyway). Here is a code extract to show the use of this function.

Message DB "Hello! This is a test.$"

        ...
        mov ah,9
        mov dx,offset Message
        int 21xH
        ...
There are a few new things in this code extract. The first is the text following the DB command. You may already know that all text in computers is actually stored as numbers. Every letter, punctuation mark, etc is stored as a byte of data.