INT (x86 instruction)
Encyclopedia
INT is an assembly language
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

 instruction for x86 processors
Central processing unit
The central processing unit is the portion of a computer system that carries out the instructions of a computer program, to perform the basic arithmetical, logical, and input/output operations of the system. The CPU plays a role somewhat analogous to the brain in the computer. The term has been in...

 that generates a software interrupt. It takes the interrupt number formatted as a byte
Byte
The byte is a unit of digital information in computing and telecommunications that most commonly consists of eight bits. Historically, a byte was the number of bits used to encode a single character of text in a computer and for this reason it is the basic addressable element in many computer...

 value.

When written in assembly language, the instruction is written like this:
INT X


where X is the software interrupt that should be generated (0-255).

Depending on the context, compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

, or assembler
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

, a software interrupt number is often given as a hexadecimal
Hexadecimal
In mathematics and computer science, hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen...

 value, sometimes with a prefix 0x or the suffix h. For example, INT 21H will generate the software interrupt 0x21 (33 in decimal), causing the function pointed to by the 34th vector in the interrupt table to be executed, which is typically an MS-DOS API
MS-DOS API
The MS-DOS API is an API used originally in MS-DOS/PC-DOS, and later by other DOS systems. Most calls to the DOS API invoke software interrupt 21h . By calling INT 21h with a subfunction number in the AH processor register and other parameters in other registers, one invokes various DOS services...

 call.

Real mode

When generating a software interrupt, the processor calls one of the 256 functions pointed to by the interrupt address table, which is located in the first 1024 bytes of memory while in real mode
Real mode
Real mode, also called real address mode, is an operating mode of 80286 and later x86-compatible CPUs. Real mode is characterized by a 20 bit segmented memory address space and unlimited direct software access to all memory, I/O addresses and peripheral hardware...

 (See Interrupt vector
Interrupt vector
An interrupt vector is the memory address of an interrupt handler, or an index into an array called an interrupt vector table that contains the memory addresses of interrupt handlers...

). It is therefore entirely possible to use a far-call instruction to start the interrupt-function manually after pushing the flag register.

One of the most useful DOS software interrupts was interrupt 0x21. By calling it with different parameters in the registers (mostly ah and al) you could access various IO operations, string output and more.

Most Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 systems and derivatives do not use software interrupts, with the exception of interrupt 0x80, used to make system call
System call
In computing, a system call is how a program requests a service from an operating system's kernel. This may include hardware related services , creating and executing new processes, and communicating with integral kernel services...

s. This is accomplished by entering a 32-bit value corresponding to a kernel function into the EAX register of the processor and then executing INT 0x80.

INT 3

The INT 3 instruction is defined for use by debuggers to temporarily replace an instruction in a running program, in order to set a breakpoint. Other INT instructions are encoded using two bytes. This makes them unsuitable for use in patching instructions (which can be one byte long). (see SIGTRAP
SIGTRAP
On POSIX-compliant platforms, SIGTRAP is the signal sent to a process when a condition arises that a debugger has requested to be informed of. In source code, SIGTRAP is a symbolic constant defined in the header file signal.h. Signal names are used instead of bare numbers because signal numbers can...

)

The opcode for INT 3 is 0xCC, as opposed to the opcode for INT immediate, which is 0xCD imm8. According to Intel documentation: "Intel and Microsoft assemblers will not generate the CD03 opcode from any mnemonic" and 0xCC has some special features, which are not shared by "the normal 2-byte opcode for INT 3 (CD03)" [IA-32 Arch. Software Developer’s Manual. Vol. 2A]

See also

  • INT 10H
  • INT 13H
  • INT 14H
    INT 14H
    - INT 14H, the serial communication interrupt :AH=00h—init Comm PortAH=01H—Write CharacterAH=02H—Read CharacterAH=03H—Status Request...

  • INT 21H
  • Interrupt
    Interrupt
    In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution....

  • Hardware interrupt
  • BIOS interrupt call
    BIOS interrupt call
    BIOS interrupt calls are a facility that DOS programs and some other software, such as boot loaders, use to invoke the facilities of the Basic Input/Output System...

  • Ralf Brown's Interrupt List
    Ralf Brown's Interrupt List
    Ralf Brown's Interrupt List or RBIL is a comprehensive list of interrupts, calls, hooks, interfaces, data structures, memory and port addresses, and processor opcodes for x86 for machines from the very start of the PC era in 1981 up into the year 2000, most of it still applying to PCs today as well...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK