int instruction (software interrupt instruction)

Source: Internet
Author: User
Tags call back

INT (software interrupt instruction) is a special form of call instruction. The call instruction calls the subroutine that is part of the user program, while the int instruction invokes the operating system to provide the subroutine or other special subroutine.

The biggest difference between an interrupt service subroutine and a standard procedure is that the assembler can have any process, and the interrupt service subroutine has a maximum of 256 processes,

There are four different formats in the INT directive:

"1" int n

n is the interrupt number, which allows a user program to invoke 256 interrupt service subroutines.

The instruction is 2 bytes long, the first byte is the int machine code, the second byte is a 8-bit immediate number, indicating the interrupt number.

When the CPU executes the int instruction, it finds the address of the interrupt service subroutine that corresponds to the interrupt number by the interrupt descriptor, (essentially a software call of an exception handler)

"2" INT 3

INT 3 is a special form of interrupt instruction with only one byte long.

The debugger uses the directive as a software interrupt instruction. When debugging, when a breakpoint is added to a location in the program, the debugger replaces the first byte of the instruction code at the breakpoint with the encoding of the int 3 instruction.

When the program executes to int 3 and requests a system call back to the debugger, the debugger gains CPU control. After that, replace the int 3 encoding with the original encoding.

"3" into interrupt No. 4

If the overflow flag bit is 1, the into instruction generates a software interrupt, which can be used to quickly test whether an overflow occurs after the arithmetic operation instruction.

"4" BOUND Interrupt No. 5

BOUND Reg,mem

Its execution algorithm is: if (Reg<[mem]) or (Reg>[mem+sizeof (REG)]) then INT 5

Determine whether the following table is within a reasonable range, an unreasonable trigger int 5 interrupt, the return address is still bound

Either way, it's going to happen.

(1) Flag register into the stack

(2) Cs:eip register into the stack,

(3) by the interrupt number in the Interrupt Descriptor table to find the corresponding descriptor, and the corresponding data into the CS:EIP,

CS into the stack and the stack is a 32-bit value, only the low 16 bits are valid. The expanded high 16-bit is undefined to keep the stack aligned with the 4-byte boundary. This is important for the performance of 80386 ... .....

int instruction (software interrupt instruction)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.