🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #273

Re: gcc for 68332 and Position Independent Code/data

#273
From: Graham Stoney
Date: Tue, 18 Aug 1992 01:32
42 lines
2604 bytes
suresh@pi.COM (Suresh Kumar) writes:
>I am planning to use gcc to cross compile code for a Motorola
>68332 based hardware.  It was not clear from the documentation
>whether gcc-2.2.2  supports the following features.

I did this with gcc 1.40 and it worked really well, although I took a long
time configuring it and working out what tools I needed (but that should be
much easier in 2.2.2).

>1.  Has anybody on the net used gcc to generate Motorola 68332
>    instructions? 68332 instruction set is a superset of 68010
>    but a subset of 68020.

You just configure it to generate 68010 code in the config file, or pass
-m68000 on the gcc command line every time you compile. I'm not sure if gcc
uses any of the exotic 68020 addressing modes that the CPU32 doesn't have;
I'd be interested to find out. Note that the CPU32 _won't_ give you an
exception if it hits an unimplemented one, your code will just do the wrong
thing. I stuck with the lowest common denominator to be safe.

>2.  Can gcc generate PIC (Position Independent Code/Data) such that
>    all instructions are PC-relative with 32bit offset  and global/static
>    data is Ax register indirect with 32 bit offset? (Ax is one of the
>    address registers). Before I execute the code, I would set up the
>    Ax register to the data segment and then jump to the first instruction
>    in the text segment.

Consider whether you really need to do this. From what you go on to say, it
sounds like all you want to do is use the -Ttext and -Tdata switches to the
linker to relocate the code or data somewhere other than starting at 0.
Unless your dynamically loading programs in and out at different locations
each time (in a microcontroller? :-), you don't need PIC at all, and it's a
liability because it slows you down. (Also I think the real answer to your Qn
is "no" 2.2.2 doesn't support it [yet]).

Good luck,
Graham

-- 
Graham Stoney                    | "a Perl script is correct if it's halfway
Flip Dibner fan club, "Hi Flip!" |  readable and gets the job done before your
Ph: +61 2 805-2909  Fax: -2929   |  boss fires you." L. Wall & R. Schwartz
Technical Details
Message-ID: <Bt5oAB.4Bv@research.canon.oz.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!mama!greyham
References: <113@benjii.UUCP>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!mama!greyham
From: greyham@research.canon.oz.au (Graham Stoney)
Subject: Re: gcc for 68332 and Position Independent Code/data
Message-ID: <Bt5oAB.4Bv@research.canon.oz.au>
Keywords: 68332, PIC
Sender: news@research.canon.oz.au
Organization: Canon Information Systems Research Australia
References: <113@benjii.UUCP>
Date: Tue, 18 Aug 1992 01:32:34 GMT
Lines: 42