This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Microtech m68k cc/as compatablity


Matthew Fletcher <amimjf@hotmail.com> wrote:

> With microtech you can force the compiler to (NOT) generate pc relative 
> code, i.e with absolute addresses, is there an equiverlent for gcc/as. ??

By default gcc generates all code with absolute references, except for branches
and calls. You can't really made branches absolute, but they are all intra-
function, so I can't see why you would need that. Calls can be made absolute by
giving as a -S option when assembling gcc-generated code.

Traditionally this has been the only type of code that gcc could generate. This
type of code is suitable for environments where you know at build time exactly
where your whole program, code and data, will reside in the address space at
run time. The current CVS version has an -mpcrel option to generate PC-relative
references for all code and data. This is suitable for environments where you
don't know exactly where you'll end up in the address space, but you know that
your whole program, both code and data, will float around as one piece,
allowing PC-relative references to anywhere. I will soon be contributing a new
code generation mode for m68k gcc to support "split PIC" environments where
different sections of your program (code and data separately) end up at
unpredictable addresses independently of each other, so that not even PC-
relative references work anywhere.

There is one problem, however, both with the currently supported -mpcrel in gcc
and the -msplit-pic that I will soon be contributing. An important feature of
most UNIX and UNIX-style assemblers, including GNU as, which is extensively
depended upon by most UNIX and UNIX-style compilers, including gcc, is the so-
called relaxation. In most architectures, including m68k, branch instructions
come in several sizes, and you must choose to correct size. Relaxation is a
feature of the assembler (and sometimes the linker) that chooses the branch
size for your automatically, picking short where possible and resorting to long
where necessary.

On m68k all branches defined in the instruction set are PC-relative. A problem
with the current GNU as for m68k is that its relaxer will sometimes turn some
branches into absolute jumps. This is OK for environments like UNIX where you
know your exact location in the address space and absolute and PC-relative
references work equally well, but is obviously a buster where you must keep
your branches PC-relative.

I have submitted a patch for gas adding a --pcrel option to keep all branches
always PC-relative. It's currently waiting for approval by Nick Clifton, the
GNU Binutils maintainer.

> what registers does gcc trash when calling 
> returning from calls. ??

By default D0, D1, A0, and A1. You can change this with -fcall-used-red and
-fcall-saved-red, see the gcc documentation.

--
Michael Sokolov		Harhan Engineering Laboratory
Public Service Agent	International Free Computing Task Force
			International Engineering and Science Task Force
			615 N GOOD LATIMER EXPY STE #4
			DALLAS TX 75204-5852 USA

Phone: +1-214-824-7693 (Harhan Eng Lab office)
E-mail: msokolov@ivan.Harhan.ORG (ARPA TCP/SMTP) (UUCP coming soon)

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]