Wojtek Wencel
Wojtek Wencel

Reputation: 2117

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.

Upvotes: 0

Views: 4344

Answers (2)

Febriyanto Nugroho
Febriyanto Nugroho

Reputation: 563

Simple answer is int 10h (I think your code has a typo) typically calls a real mode interrupt handler at the vector that provides video services. int 10h services include setting the video mode, character and string output, and graphics primitives (reading and writing pixels in graphics mode).

Upvotes: 1

Michael Petch
Michael Petch

Reputation: 47573

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.

Upvotes: 6

Related Questions