Why 0x80?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
Coomer69
Member
Member
Posts: 31
Joined: Thu Feb 20, 2014 4:49 am

Why 0x80?

Post 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?

:-"
Last edited by Coomer69 on Mon Aug 03, 2020 2:01 pm, edited 2 times in total.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Why 0x80?

Post 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).
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: Why 0x80?

Post 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.
Coomer69
Member
Member
Posts: 31
Joined: Thu Feb 20, 2014 4:49 am

Re: Why 0x80?

Post 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?
no92
Member
Member
Posts: 307
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: Why 0x80?

Post 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 :D
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: Why 0x80?

Post by Muazzam »

no92 wrote: Oops, I meant 100 decimal :D
I used 100 decimal for interrupt in my OS.
Coomer69
Member
Member
Posts: 31
Joined: Thu Feb 20, 2014 4:49 am

Re: Why 0x80?

Post 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 :)
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why 0x80?

Post 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.
tom9876543
Member
Member
Posts: 170
Joined: Wed Jul 18, 2007 5:51 am

Re: Why 0x80?

Post 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?
Post Reply