POV-Ray : Newsgroups : povray.off-topic : Linking : Re: Linking Server Time
2 Jul 2024 23:48:09 EDT (-0400)
  Re: Linking  
From: scott
Date: 1 Jun 2016 03:22:28
Message: <574e8d34@news.povray.org>
> The way AmigaOS does it, memory address 0x00000004 holds a pointer to
> the function table for exec.library. Every function in the library has a
> known index in that table, so by adding your index to the address
> pointed to, you get a function pointer to the actual library function
> that you want. Now since exec.library is the one that contains the
> functions to load *other* libraries, from here you can open any other
> library you want. This similarly returns a function table base pointer,
> which you can use in the same way.
>
> Of course, exec.library is in ROM, as are most of the low-level system
> libraries [including the entire GUI]. But you don't need to care about
> that. Just call OpenLibrary(), and it'll load from disk if required, and
> ultimately give you back a base pointer.
>
> 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.)

Not a protected-mode OS, but in RISCOS on ARM there is an instruction 
"SWI" that triggers a software interrupt. There are 24 bits spare in 
that instruction to specify the routine number (the other 8 to identify 
the instruction itself and conditional execution flags etc). Routines 
have a name and a number, the OS maintains a list if you can only 
remember the name (in fact most compilers/interpreters will allow you to 
write the name, and automatically substitute the number to the 
instruction). The processor registers r0 up to r8 (IIRC) were passed on 
to the SWI handler code and returned, so these were used for parameters 
and return values.

It was possible to add your own routines to this system, in fact this is 
how almost all 3rd party libraries (eg music players, image converters, 
compression software,...) were written. The equivalent of how DLLs are 
used today I guess.


Post a reply to this message

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