POV-Ray : Newsgroups : povray.off-topic : Linking : Re: Linking Server Time
3 Jul 2024 00:19:01 EDT (-0400)
  Re: Linking  
From: Orchid Win7 v1
Date: 1 Jun 2016 12:59:28
Message: <574f1470$1@news.povray.org>
On 31/05/2016 07:57 PM, clipka wrote:
> Am 29.05.2016 um 09:48 schrieb Orchid Win7 v1:
>
>> I was *about* to say that I've only done it with AmigaOS - but that's
>> not quite right. What I was *actually* looking it is calling *the OS*,
>> which is a bit different.
> ...
>> Presumably any self-respecting protected-mode OS does it differently. In
>> particular, calling the kernel presumably implies a transition to
>> ring-0, and I don't remember how x86 does that exactly. (From what I
>> dimly recall, you purposely trigger a kind of software interrupt, but
>> I'm not sure how you designate what function you're trying to call.)
>
> That's pretty simple: You pass a kind of function ID in a particular CPU
> register.
>
> For instance, in good old DOS, the sole entry point for all operating
> system functions was INT 21h, with the AH register indicating which
> function you intended to call.

That's essentially a direct call to the BIOS itself, isn't it? Or does 
MS-DOS actually interact with this somehow? (I realise that MS-DOS is a 
very thin "OS", if you can even call it that.)

> According to Wikipedia, Linux originally used pretty much the same
> principle, except with INT 80h and the AX register.

OK...

> Windows also uses the AX register to identify the kernel function, but
> uses the faster dedicated SYSENTER instruction (introduced with the
> Pentium II) instead of a software interrupt. (The drawback is that this
> instruction doesn't push a return address onto the stack, so a CALL to a
> stub is usually employed.)
>
> Likewise, Linux running on modern machines also uses SYSENTER or the
> even newer SYSCALL.

OK, fair enough.

Both IA32 (and later AMD64) are quite short on registers, which is 
presumably why the default C calling convention is seemingly via the 
stack. In AmigaOS, running on a Motorola 68000 with a dozen registers, 
most of this stuff is via register...

> The x86 architecture also provides a mechanism known as a "call gate",

Yeah, I remember reading about that in the IA32 reference manual. I 
can't recall the details of how it works though.

> This mechanism was used by some
> operating systems, but has gone out of style.

OK. Sounds like there's not much point remembering then.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.