http://en.wikipedia.org/wiki/System_call
For many RISC processors this is the only feasible implementation, but CISC architectures such as x86 support additional techniques. One example is SYSCALL/SYSENTER, SYSRET/SYSEXIT (the two mechanisms were independently created by AMD and Intel, respectively, but in essence do the same thing). These are "fast" control transfer instructions that are designed to quickly transfer control to the OS for a system call without the overhead of an interrupt. Linux 2.5 began using this on the x86, where available; formerly it used the INT instruction, where the system call number was placed in the EAX register before interrupt 0x80 was executed.
Może ktoś podać jakiś przykład kodu wykorzystujący jawnie SYSENTER/SYSCALL? Nie mogę doszukać się informacji jak przekazywać dane, które normalnie siedziałyby w edx/rdx. Jeżeli leży to gdzieś na samym początku google, to przepraszam, może złe zapytania formułuje o tej godzinie :P
Żeby nie utrudniać podaję wzorcowy kod z intem ;)
int main(void) {
char* c = "str";
asm(
"movq $4, %%rax\n"
"movq $1, %%rbx\n"
"movq $4, %%rdx\n"
"int $0x80\n"
:
: "c" (c)
);
return 0;
}
Pisane pod 64b, ale proszę używać 32b jeśli wygodniej :)