DGivney / assemblytutorials

This project was put together to teach myself NASM x86 assembly language on linux.
https://asmtutor.com/
654 stars 117 forks source link

int 80h is deprecated, prefer syscall? #8

Closed catb0t closed 6 years ago

catb0t commented 7 years ago

From what I've read, "int 80h to call the Linux Kernel" is deprecated.

From Stack Overflow What is better on x86, “int 0x80” or “syscall”?:

  • syscall is default way of entering kernel mode on x86-64. This instruction is not available in 32 bit modes of operation on Intel processors.
  • 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 kernel's concern.
  • int 0x80 is a legacy way to invoke a system call and should be avoided.

So for code that works on both 32- and 64-bit, syscall should be used. For multiarch code to run under 32-bit mode on a 64-bit processor, sysenter should be used.

I'm excited to find http://asmtutor.com with the amount of information it has but I'm rather disappointed there is not even a mention of syscall.

The system call numbers are different between int 80h and syscall.

This is a table about the syscall numbers and this is one for int 80h.

Do you think this change is worth it?

DGivney commented 6 years ago

Hi catb0t

Thank you for your interest in this repo and apologies for the delay in replying to you.

My plan for these tutorials was to slowly move from the 32-bit syntax into the 64-bit syntax and eventually into a much more modern example of assembly on linux. I wanted to show the history of the registers & naming conventions etc. The int 80h therefore was chosen to show that evolution out of the legacy x86 interrupts where I was to eventually introduce syscall with 64-bit registers.

Unfortunately time got the best of me and I never completed all the tutorials to show that.