[comp.realtime] compiling 68000 code on a Sun 3

unhd (Roger Gonzalez ) (12/05/90)

I need to be able to compile plain 68000 code on a Sun 3 to be prommed
into an embedded system.  It looks like as and gas can assemble 68020
and 68010 code (or, if you prefer, gcc and cc can *produce* 680[12]0 code.)
I need to be able to do the whole thing; from compilation to assembly to
link.  Am I in trouble?

-Roger

-- 
"The question of whether a computer can think is no more interesting
 than the question of whether a submarine can swim" - Edsgar W. Dijkstra 
rg@unhd.unh.edu               |  UNH Marine Systems Engineering Laboratory
r_gonzalez@unhh.bitnet        |  Durham, NH  03824-3525

wgstuken@faui4n.informatik.uni-erlangen.de (Wolfgang Stukenbrock (Dipl. Zugangssystem Inf4)) (12/07/90)

rg@uunet!unhd (Roger Gonzalez ) writes:

>I need to be able to compile plain 68000 code on a Sun 3 to be prommed
>into an embedded system.  It looks like as and gas can assemble 68020
>and 68010 code (or, if you prefer, gcc and cc can *produce* 680[12]0 code.)
>I need to be able to do the whole thing; from compilation to assembly to
>link.  Am I in trouble?

Yes you are!

There are two main problems.
1. Sun
  Sun wants to sell you the cross-development-package and so the cc suplied
  with your sun3 won't generate plain 680[01]0 code. The "-sun3" (for 4.0.3)
  or the "-target sun2" (for 4.1) wont work without the cross-development-
  extentions. I suppose "as" does the same (not testet - I fixed gas to work)
2. GNU
  The gas doesn't work correct on sun3!!!!! There are problems (never fixed by FSF)
  that make it incompartible to the as. These are not only syntax-problem
  there is a GREAT BUG in gas, that brings semantik-problems with the bss
  segment. Under 4.0.3 (we are still running 4.0.3, because sun isn't able
  to ship the sources) it was poosible to install gas (with a lot of work)
  but under 4.1 I dont know if it is still possible. (on Sparc these
  semantik-problems make it impossible to use gas!)

If you got a correct objectfile, everythings done. "ld", "ar", "ranlib, etc. works!

Wolfgang (wgstuken@immd4.informatik.uni-erlangen.de)

byron@cc.gatech.edu (Byron A Jeff) (12/07/90)

In article <wgstuken.660513920@faui4n> wgstuken@faui4n.informatik.uni-erlangen.de (Wolfgang Stukenbrock (Dipl. Zugangssystem Inf4)) writes:
>rg@uunet!unhd (Roger Gonzalez ) writes:
>
>>I need to be able to compile plain 68000 code on a Sun 3 to be prommed
>>into an embedded system.  It looks like as and gas can assemble 68020
>>and 68010 code (or, if you prefer, gcc and cc can *produce* 680[12]0 code.)
>>I need to be able to do the whole thing; from compilation to assembly to
>>link.  Am I in trouble?
>
>Yes you are!
>
>There are two main problems.
>[1. Sun wants to sell cross development system and ...
> 2. GNU doesn't work properly]

Well while it's true it won't work straight up and down it is possible
to get the Sun development environment for generate code for
vanilla 68000 systems.

What I did was to generate a sed script to change the few 68020
specific assembler items the cc compiler generated into 68010 eqivalents.
The ones in particular are:

1. Changing extbl to an extw followed by an extl
2. Hand scaling the automatic scaling that the 68020 uses.

I can't even parse what I dd anymore. Find a copy of the script below.

So the process I use:

1. Compile C programs with SUN cc producing assembler.
2. Run the assembler code through the script below generating
   code with only 68000 directives.
3. Run the assembler code through as with the -mc68010 switch on to
   catch any bad directives.

Note that the best you can do is generate 68010 code. You'll need additional
code to catch 68010 directives but I don't think the cc compiler generates
any.

Anyway this has worked on both a 68008 and a 68010 system I've built.

Feel free to write if you have any questions.

BAJ
------ CUT HERE -------
# Conversion script for 68020 assembler directives to 68000 assembler
# directives.
#
# Copyright 1990 - Byron A. Jeff
#
# Feel free to distribute under the following conditions:
#
# 1. The header accompany all copies
# 2. Source is not used in any commercial ventures
#

/extbl/ {
s/extbl/extw/
p
s/extw/extl/
p
d
}
/,.*:.*:.*)/ {
s/^\(.*:.*\):2)\(.*\)$/\1:1)\2/
s/^\(.*:.*\):4)\(.*\)$/\1:2)\2/
s/^\(.*:.*\):8)\(.*\)$/\1:3)\2/
h
s/^.*,\(.*\):\([^,)]*\):\(.*\)).*$/	lsl\2	#\3,\1/
t x1
b cont1
:x1
p
:cont1
g
s/,\(.*\):\([^,)]*\):\(.*\))/,\1:\2)/
t x2
b cont2
:x2
p
:cont2
g
s/^.*,\(.*\):\([^,)]*\):\(.*\)).*$/	lsr\2	#\3,\1/
}
--------- End of included text --------
---
Another random extraction from the mental bit stream of...
Byron A. Jeff - PhD student operating in parallel!
Georgia Tech, Atlanta GA 30332   Internet: byron@cc.gatech.edu

jeff@uf.msc.umn.edu (Jeff Turner) (12/07/90)

In article <1990Dec5.031024.5958@uunet!unhd> rg@unhd.UUCP (Roger Gonzalez ) writes:
>I need to be able to compile plain 68000 code on a Sun 3 to be prommed
>into an embedded system.  It looks like as and gas can assemble 68020
>and 68010 code (or, if you prefer, gcc and cc can *produce* 680[12]0 code.)
>I need to be able to do the whole thing; from compilation to assembly to
>link.  Am I in trouble?

Can't you configure GCC so that it produces 68000 code?  A quick glance at
the config files suggests that it can configured to do so.

I have an SBC application that has been developed entirely on a Sun 3 running
Sun OS 3.someting .  I use GCC to create 68020 code, and normal Sun AS and LD
to assemble and link.  Of course, I supply my own libraries and include files
so as not to use Sun's.

If your question is "Can I develop prommable code on a Sun", the answer is "yes".
If your question is "Can I generate 68000 code", the answer is "GCC looks like
it will".

-Jeff
---
Jeff Turner                  Minnesota Supercomputer Center, Inc.
(612) 626-0544               1200 Washington Avenue South
jeff@uh.msc.umn.edu          Minneapolis, Minnesota  55415

pl@news.funet.fi.tut.fi (Lehtinen Pertti) (12/07/90)

From article <wgstuken.660513920@faui4n>, by wgstuken@faui4n.informatik.uni-erlangen.de (Wolfgang Stukenbrock (Dipl. Zugangssystem Inf4)):
> rg@uunet!unhd (Roger Gonzalez ) writes:
> 
>>I need to be able to compile plain 68000 code on a Sun 3 to be prommed
>>into an embedded system.  It looks like as and gas can assemble 68020
>>and 68010 code (or, if you prefer, gcc and cc can *produce* 680[12]0 code.)
>>I need to be able to do the whole thing; from compilation to assembly to
>>link.  Am I in trouble?
> 
> Yes you are!
> 
> There are two main problems.
> 1. Sun
>   Sun wants to sell you the cross-development-package and so the cc suplied
>   with your sun3 won't generate plain 680[01]0 code. The "-sun3" (for 4.0.3)
>   or the "-target sun2" (for 4.1) wont work without the cross-development-
>   extentions. I suppose "as" does the same (not testet - I fixed gas to work)

	Well, for me 'cc -mc68010' worked just ok without any cross dev package ...

	We produced code for SCC68070, and no problems in this area arised.

	Most problems you will get with loader, as it is not very easy
	tell it to start addresses for code and data, we used simple catenation
	with 'ld -N' and sun default address (0x2000) happens to be ok for us.

--
pl@tut.fi				! All opinions expressed above are
Pertti Lehtinen				! purely offending and in subject
Tampere University of Technology	! to change without any further
Software Systems Laboratory		! notice

wgstuken@faui4n.informatik.uni-erlangen.de (Wolfgang Stukenbrock (Dipl. Zugangssystem Inf4)) (12/09/90)

pl@news.funet.fi.tut.fi (Lehtinen Pertti) writes:
>	Well, for me 'cc -mc68010' worked just ok without any cross dev package ...

Yes, you are right! But about this option nothing is said in the man-pages.
So I don't find it!

I don't understand your loader-problems.
With -T[text] and -Tdata you may specify any start address!
I've done it for an 68020 system with both to 1024 - using functioncode in
addresstranslation.

Wolfgang

jeff@uf.msc.umn.edu (Jeff Turner) (12/11/90)

In article <1990Dec7.145400.26717@funet.fi> pl@news.funet.fi.tut.fi (Lehtinen Pertti) writes:
>
>	Most problems you will get with loader, as it is not very easy
>	tell it to start addresses for code and data, we used simple catenation
>	with 'ld -N' and sun default address (0x2000) happens to be ok for us.

The following LD command locates the code segment at address 0x10000 and
places the data and BSS segments immediately after it.

	ld -T 10000 -d -e _start -o output.bin  a.o b.o c.o ...

The addition of a "-Tdata addr" would allow you to locate the data and
BSS segments elsewhere (e.g. in RAM).

-Jeff
---
Jeff Turner                  Minnesota Supercomputer Center, Inc.
(612) 626-0544               1200 Washington Avenue South
jeff@msc.edu                 Minneapolis, Minnesota  55415