Can someone explain what the following assembly code does?
int 0x80
int 0x80 Definition int 0x80 is the assembly language instruction that is used to invoke system calls in Linux on x86 (i.e., Intel-compatible) processors. An assembly language is a human-readable notation for the machine language that a specific type of processor (also called a central processing unit or CPU) uses.
INT is an assembly language instruction for x86 processors that generates a software interrupt. It takes the interrupt number formatted as a byte 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).
sysenter is an instruction most frequently used to invoke system calls in 32 bit modes of operation. It is similar to syscall , a bit more difficult to use though, but that is the kernel's concern. int 0x80 is a legacy way to invoke a system call and should be avoided.
EAX register, a 32-bit processor register of x86 CPUs. Environmental Audio Extensions, a number of digital signal processing presets for audio, found in Sound Blaster sound cards.
int
means interrupt, and the number 0x80
is the interrupt number. An interrupt transfers the program flow to whomever is handling that interrupt, which is interrupt 0x80
in this case. In Linux, 0x80
interrupt handler is the kernel, and is used to make system calls to the kernel by other programs.
The kernel is notified about which system call the program wants to make, by examining the value in the register %eax
(AT&T syntax, and EAX in Intel syntax). Each system call have different requirements about the use of the other registers. For example, a value of 1
in %eax
means a system call of exit()
, and the value in %ebx
holds the value of the status code for exit()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With