🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #6481

Re: Lattice C : pragma? Whats all this then?

#6481
From: Staff OACIS
Date: Fri, 09 Nov 1990 18:29
52 lines
3338 bytes
In article <1990Nov10.001056.9736@canterbury.ac.nz> cctr120@canterbury.ac.nz (Brendon Wyber, C.S.C.) writes:
>Hi,
>
>I am using Lattice C v5.05 and have been using the ProtoType files. I've
>noticed that the #pragma calls for INCLUDE:proto/cstrings.h refer to
>a variable CStringBase. 

You should not be including INCLUDE:proto/cstrings.h. The cstrings functions
were dropped some time around the release of V1.0. Why are they still there?

As for CStringsBase,...you need to understand some Amiga library fundamentals.
All Amiga libraries are dynamically referenced at run-time. The mechanism
that allows this is a library base pointer, or vector, that points to a table
of library entry points. The Amiga routine OpenLibrary returns this pointer
value.

All the routines in Amiga.lib are hard-coded to use library vectors with
specific names. The #pragma statements use the same names in order to be
compatible with the non-#pragma mechanism. These names are all of the form
"xxxxxBase" where "xxxxx" is related to the library name. Hence, dos.library
is DosBase, intuition.library is IntuitionBase, etc.

It is the responsibility of the applications code to define these. Some time
back Lattice added them to the standard run-time library to help eliminate
confusion when the same base was defined in multiple modules, especially when
they were compiled with different options. (Note that ExecBase is hard-wired
at location 0x0004, and DosBase is defined in c.o). CStringsBase was left
out because this library is not supported (or even available, if memory
serves me).

>Also what difference do Pramgas make? Is it done so that I can link to less
>things? IE use my own c.o and miss out amiga.lib and lc.lib, (all in the
>search for smaller code :-) ).

#pragma support makes your code smaller and faster (in general). Without them,
calls to Amiga libraries actually call stub routines that save the registers,
load arguments off the stack into appropriate registers (Amiga libraries take
arguments in registers), load the library base vector into A6, and branch to
the real routine.

With #pragmas, the compiler generates the code to load the appropriate registers
in-line, and directly calls the library routine based on the library base vector.
This eliminates the argument pushing and popping, and allows the compiler to
optimize register allocation and usage around the call. Also, since the call
is direct, the stub code doesn't have to be linked in, making the code a little
smaller.

-- 
John Meissen .............................. Oregon Advanced Computing Institute
jmeissen@oacis.org        (Internet) | "That's the remarkable thing about life;
..!sequent!oacis!jmeissen (UUCP)     |  things are never so bad that they can't
jmeissen                  (BIX)      |  get worse." - Calvin & Hobbes
Technical Details
Message-ID: <63@oregon.oacis.org>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!decwrl!ogicse!oregon!jmeissen
References: <1990Nov10.001056.9736@canterbury.ac.nz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!decwrl!ogicse!oregon!jmeissen
From: jmeissen@oregon.oacis.org ( Staff OACIS)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Lattice C : pragma? Whats all this then?
Message-ID: <63@oregon.oacis.org>
Date: 9 Nov 90 18:29:24 GMT
References: <1990Nov10.001056.9736@canterbury.ac.nz>
Organization: Oregon Advanced Computing Institute (OACIS)
Lines: 52