Search code examples
assemblyinterruptdosmasmx86-16

What is int 10 doing in assembly?


I'm trying to learn assembly for school and there is this part at the beginning of the example code:

mov al, 0
mov ah, 5
int 10

Before this there is a procedure :

.386
instructions SEGMENT use16
        ASSUME  CS:instructions

interrupt_handler PROC
; some code
interrupt_handler ENDP

What is the int 10 line doing? Is it calling the interrupt_handler procedure? Why is it exactly 10?

This is all running in DoSBox and is assembled using masm.


Solution

  • I found what appears to be a complete copy of the code in the OPs native language (Polish). https://ideone.com/fork/YQG7y . There is this section of code (run through Google translate):

    ; ================================================= =======
    
    ; main program - installation and uninstallation of the procedure
    ; interrupt handling
    
    ; determining page number 0 for text mode
    start:
    mov al, 0
    mov ah, 5
    int 10
    

    It is clear from this code that it is a bug. It should be int 10h and not int 10 (same as int 0ah). int 10h is documented as:

    VIDEO - SELECT ACTIVE DISPLAY PAGE
    AH = 05h
    AL = new page number (00h to number of pages - 1) (see #00010)
    
    Return:
    Nothing
    
    Desc: Specify which of possibly multiple display pages will be visible
    

    int 10 is something completely different:

    IRQ2 - LPT2 (PC), VERTICAL RETRACE INTERRUPT (EGA,VGA)
    

    Calling IRQ2 interrupt handler with int 10 will effectively do nothing from the standpoint of the program. Since the default text page is likely already 0 the program works as expected.


    The correct code:

    mov al, 0
    mov ah, 5
    int 10h
    

    would set the text mode display page to 0 using the BIOS service 10h function 5.