Can someone explain what the following assembly code does?
int 0x80
Can someone explain what the following assembly code does?
int 0x80
It passes control to interrupt vector 0x80
See http://en.wikipedia.org/wiki/Interrupt%5Fvector
On Linux, have a look at this: it was used to handle system_call
. Of course on another OS this could mean something totally different.
int 0x80 is the assembly language instruction that is used to invoke system calls in Linux on x86 (i.e., Intel-compatible) processors.
It tells the kernel to activate interrupt vector 0x80, which on Linux OSes is the system-call interrupt, used to invoke system functions like open()
for files, et cetera.
As mentioned, it causes control to jump to interrupt vector 0x80. In practice what this means (at least under Linux) is that a system call is invoked; the exact system call and arguments are defined by the contents of the registers. For example, exit() can be invoked by setting %eax to 1 followed by 'int 0x80'.
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 (gas 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()
.