   linux asm, interrupt kernel with exit, or simply ret?
  Both seem to work just the same, but which is 'correct'?on exit of program, either:mov eax, exitcoderetormov eax, 1mov ebx, exitcodeint 0x80   
The C runtime contains a _start() entrypoint which basically does "exit(main())" anyway.Either way is reasonable. The first is returning from main(), the second is (effectively) what you get if you call exit(). They're both acceptable ways of terminating the program.It's probably nicer to actually call exit() rather than invoke the interrupt yourself though. Why? Because on modern CPUs, calling an interrupt can be quite slow -- especially if the machine is virtualised where it requires a switch into the hypervisor to handle the int initially (the HV sits in ring0 and displaces the OS, unless this is a hardware HV 64b machine in which case it gets even more fiddly). Then there's a transfer back to the VM supervisor mode and only then can it do the work.So these days there are fast transition instructions which switch to the OS rather than to the hypervisor, and which execute faster than interrupts (even on non-virtualised systems). Of course, there are two sets of these (AMD's & Intel's) so there's some boot-time choices to set up. The plumbing to do all that is hidden inside the system calls, so apps don't need to worry about it.;  You really shouldn't call int 0x80 directly in Linux. The kernel can be subject to change so what works now, may not work later on.   ;Quote:Original post by Chris_FYou really shouldn't call int 0x80 directly in Linux. The kernel can be subject to change so what works now, may not work later on.Realistically, this will not change. The conventions of the unix system calls predate Linux, I don't think there has been significant change there for some time.   