[fpc-pascal] location modifier

Karoly Balogh (Charlie/SGR) charlie at scenergy.dfmk.hu
Mon Jan 18 16:59:49 CET 2016


Hi,

On Mon, 18 Jan 2016, Mattias Gaertner wrote:

> I can't find the 'location' modifier in the docs. Is it missing?
>
> For example:
>
> function bsd_socket(Domain: LongInt location 'd0'; Type_: LongInt
> location 'd1'; Protocol: LongInt location 'd2'): LongInt; syscall
> SocketBase 30;
>
> See for example packages/rtl-extra/src/amiga/sockets.pp

This modifier only exist for Amiga-library ABI syscalls, therefore only
available on m68k-amiga and powerpc-morphos (where it's called the legacy
library ABI). It's there to help the compiler to know which value to put
into which register, before a library call happens. These registers are
explicitly defined in C/assembly, without any common ABI, and it's is
heavily macroed when using a a C compiler. On Amiga, we used umpzillion
asm-written/generated wrappers before syscalls existed (1.0.x times and
before), which was very ugly, slow, and bloated.

The location modified is only valid together with the syscall modifier. It
actually exists since 2005, or so, when I refused to reinvent the
umpzillion asm wrappers stunt for MorphOS, so Florian helped me to come up
with this solution.

And there's no need to take educated guesses, it's all documented in the
wiki:

http://wiki.freepascal.org/Amiga#Introduction_to_SysCalls
http://wiki.freepascal.org/MorphOS#Introduction_to_SysCalls

>From syntax PoV, the argument is always a two character string, and can
contain 'd0'-'d7', and 'a0'-'a6', which are the 68k CPU's data and address
registers, respectively.

Syscalls also exist on AROS/i386 and AROS/x86_64 (for now), but there the
locations are defined by the ABI, without the need to be specified
explicitly. In the future, I plan to reuse syscalls and the location
syntax for a possible Atari port too.

If there are any more questions, I'm happy to answer.

Charlie



More information about the fpc-pascal mailing list