Page 1 of 1
Why 0x80?
Posted: Sat Mar 07, 2015 5:51 am
by Coomer69
Is there any particular reason why the Unix/Linux developers chose 0x80 for the system call interrupt? Is there an advantage to using that particular interrupt or did they just pick it out of a hat?
Re: Why 0x80?
Posted: Sat Mar 07, 2015 6:05 am
by alexfru
It doesn't fall into the range of the CPU exception vectors or the default IRQ vectors as set up by the BIOS. Seems good enough.
In terms of the instruction set, 0x80 is no different than most other values. There's just one int n instruction (unless we're talking about int3 and into, which would be awkward to use), unlike several variants of push n (byte and word sized).
Re: Why 0x80?
Posted: Sat Mar 07, 2015 6:10 am
by no92
There's nothing special about it, you could use 0x100 as well, as long as it doesn't conflict with any predefined vectors. It's 128 in decimal, which us nice (power of two ...), but nothing more. The IDT fits 256 entries, which make this number nice in two ways. This only goes for protected mode; in long mode we have the syscall instruction.
Re: Why 0x80?
Posted: Sat Mar 07, 2015 7:01 am
by Coomer69
no92 wrote:There's nothing special about it, you could use 0x100 as well
Surely, 0x100 would be impossible since the interrupts begin at 0 and there are only 256 (0xFF) of them?
Re: Why 0x80?
Posted: Sat Mar 07, 2015 7:27 am
by no92
SapphireBeauty wrote:no92 wrote:There's nothing special about it, you could use 0x100 as well
Surely, 0x100 would be impossible since the interrupts begin at 0 and there are only 256 (0xFF) of them?
Oops, I meant 100 decimal
Re: Why 0x80?
Posted: Sat Mar 07, 2015 7:39 am
by Muazzam
no92 wrote:
Oops, I meant 100 decimal
I used 100 decimal for interrupt in my OS.
Re: Why 0x80?
Posted: Sat Mar 07, 2015 7:44 am
by Coomer69
no92 wrote:Oops, I meant 100 decimal :D
That makes more sense :)
muazzam wrote:I used 100 decimal for interrupt in my OS.
I'm using 0xFF, nice and easy to remember :)
Re: Why 0x80?
Posted: Sat Mar 07, 2015 8:54 am
by iansjack
If you are starting from scratch I think it makes a lot more sense to use sysenter/sysexit rather than an interrupt for system calls.
Re: Why 0x80?
Posted: Thu Apr 23, 2015 6:16 am
by tom9876543
According to the "Programmer's Technical Reference for MSDOS and the IBM PC", INT 0x80 was reserved for BASIC.
http://www.o3one.org/hwdocs/bios_doc/dosref22.html
The implications are obvious, INT 0x80 would never be used by hardware or the BIOS, and so it was safe for Linux to use it.
My question is.... did Linus know this fact or was there another reason he chose 0x80?