The INT n instruction

Calling a software interrupt.

The INT n instruction format

InstructionDescription
INT imm8Generate a software interrupt with the vector specified in imm8.

The INT n instruction generates a call to the interrupt or exception handler specified by the destination operand. The destination operand specifies a vector from 0 to 255, encoded as an 8-bit unsigned intermediate value. Each vector is an index into the interrupt vector table.

Table of common interrupts

VectorDescription
00hDivide by zero (automatic).
01hDebug (Step).
03hDebug (Breakpoint).
08hTimer (system clock).
09hKeyboard.
10hBIOS video service.
13hDisk input/output.
16hKeyboard input.
21hMain DOS interface.

Usage example

The most common example is terminating a program through DOS.

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

code segment public        ; Start of the code segment
    assume cs:code

    main proc              ; Start of the main procedure

        mov     ax, 4C00h  ; Copy the process termination function number into ah and the return code into al
        int     21h        ; Call the DOS interrupt
    main endp              ; End of the main procedure

code ends                  ; End of the code segment
end main                   ; End of file. The main procedure is the entry point

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Processor status flags

CF
?
PF
?
AF
?
ZF
?
SF
?
TF
Yes*
IF
Yes*
DF
?
OF
?

* — TF and IF may be cleared by the processor on entry to the handler. The final state of the flags depends on the handler that is called.