public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* cgen fundamentals
@ 2002-12-18 15:23 David Carney
  2002-12-18 17:31 ` Ben Elliston
  2002-12-19  4:51 ` Frank Ch. Eigler
  0 siblings, 2 replies; 5+ messages in thread
From: David Carney @ 2002-12-18 15:23 UTC (permalink / raw)
  To: cgen

Hey,

I was referred to cgen by a member of the binutils mailing list (Nick 
Clifton).  Being (virtually) a complete newbie to Scheme programming and 
cgen, I have a number of fairly fundamental questions that are likely best 
answered through this list, rather than trying to find information on the 
web... 

Basically, I'm a hardware engineer with a background in chip design, some 
board design, and a fair bit of embedded (C) programming.  I spent a day or 
two week teaching myself the basics of scheme, but I'm still confused about 
the exactly purpose of cgen.  I.e. what's the purpose of a 'gas' versus an 
'opcodes' port?  What does cgen actually produce (and how do I produce and 
use it) ?  How do files created with cgen interface with binutils?

All I want to do is have an assembler which dumps out object files for a 
simple, non-pipelined, 16-bit processor.  Could anyone give me some pointers 
on  where I should begin and/or how I should proceed?

A lowly hardware engineer,

Dave Carney

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: cgen fundamentals
  2002-12-18 15:23 cgen fundamentals David Carney
@ 2002-12-18 17:31 ` Ben Elliston
  2002-12-19 11:34   ` David Carney
  2002-12-19  4:51 ` Frank Ch. Eigler
  1 sibling, 1 reply; 5+ messages in thread
From: Ben Elliston @ 2002-12-18 17:31 UTC (permalink / raw)
  To: cgen

Hi David.  Welcome.

>>>>> "David" == David Carney <dfcarney@net-itech.com> writes:

  David> I was referred to cgen by a member of the binutils mailing
  David> list (Nick Clifton).  Being (virtually) a complete newbie to
  David> Scheme programming and cgen, I have a number of fairly
  David> fundamental questions that are likely best answered through
  David> this list, rather than trying to find information on the
  David> web...

This is probably the first mistake of most newcomers to CGEN -- it is
not necessary to know Scheme to write a CGEN port (although a
Scheme-aware editor can help!).  The CGEN input language just looks a
lot like Scheme, but in trying to treat them as equivalent, you'll get
yourself into more trouble than if you just consider your task to
learn ".cpu" ;-)

  David> two week teaching myself the basics of scheme, but I'm still
  David> confused about the exactly purpose of cgen.  I.e. what's the
  David> purpose of a 'gas' versus an 'opcodes' port?  What does cgen
  David> actually produce (and how do I produce and use it) ?  How do
  David> files created with cgen interface with binutils?

CGEN is a framework, in which CGEN applications run.  There are a
handful of these now: an opcodes table generator, a simulator kernel
generator, and so on.  If you just want to port binutils, you need
only concern yourself with generating the opcodes/* files.  The GNU
binutils "opcodes" directory has Makefile fragments for other ports
(like fr30) that can be duplicated almost verbatim.  These Makefile
fragment are responsible for running CGEN for you and depositing the
output files in the opcodes/ source directory.  I would suggest you
focus on writing your CPU description first and then work out how to
run it from opcodes/Makefile.

Please feel free to ask more questions on this otherwise quiet list!

Cheers, Ben


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: cgen fundamentals
  2002-12-18 15:23 cgen fundamentals David Carney
  2002-12-18 17:31 ` Ben Elliston
@ 2002-12-19  4:51 ` Frank Ch. Eigler
  1 sibling, 0 replies; 5+ messages in thread
From: Frank Ch. Eigler @ 2002-12-19  4:51 UTC (permalink / raw)
  To: David Carney; +Cc: cgen

Hi -


On Wed, Dec 18, 2002 at 06:23:41PM -0500, David Carney wrote:
> [...] I'm still confused about 
> the exactly purpose of cgen.  I.e. what's the purpose of a 'gas' versus an 
> 'opcodes' port?  

Opcodes contains table-driven kernels for assemblers and disassemblers.
CGEN can generate these parts entirely.  The assembler needs some further
hand-made code, which goes into gas/config/tc-*.  A normal assembler will
produce relocatable object files, which requires further hand-made code
in bfd/* to handle.

> What does cgen actually produce (and how do I produce and use it) ?

In general, think of CGEN like a parser generator or a state machine
translator thingie.  It can create table-driven parts of the system,
but you still need to come up with the interface code.  This is normally
done by copying another existing simple port, then modifying it to taste.

> How do files created with cgen interface with binutils? [...]

Unfortunately, the interfaces between cgen-generated code and their
callers/callees is not clearly designed.  If you were interested in the
gory details, you'd need to run the assembler under gdb while it's at
work.  It has an inner beauty, I suppose, an ugly one.


- FChE

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: cgen fundamentals
  2002-12-18 17:31 ` Ben Elliston
@ 2002-12-19 11:34   ` David Carney
  2002-12-19 14:12     ` Ben Elliston
  0 siblings, 1 reply; 5+ messages in thread
From: David Carney @ 2002-12-19 11:34 UTC (permalink / raw)
  To: cgen; +Cc: bje

> Hi David.  Welcome.

Thanks.

> CGEN is a framework, in which CGEN applications run.  There are a
> handful of these now: an opcodes table generator, a simulator kernel
> generator, and so on.  If you just want to port binutils, you need
> only concern yourself with generating the opcodes/* files.  The GNU
> binutils "opcodes" directory has Makefile fragments for other ports
> (like fr30) that can be duplicated almost verbatim.  These Makefile
> fragment are responsible for running CGEN for you and depositing the
> output files in the opcodes/ source directory.  I would suggest you
> focus on writing your CPU description first and then work out how to
> run it from opcodes/Makefile.
>
> Please feel free to ask more questions on this otherwise quiet list!

Oh, I will.  Don't worry... :)

So, basically, I define my own .cpu file and add a new target to the 
binutils/opcodes Makefile (that'll use cgen in conjunction with my .cpu 
file), correct?  After I get cgen to properly generate files for 
binutils/opcodes, I'll need to write my own cpu-???.* and elf32-???.* files 
for the binutils/bfd, right?

What else will I need to do to get an assembler up and running?

Thanks,

Dave

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: cgen fundamentals
  2002-12-19 11:34   ` David Carney
@ 2002-12-19 14:12     ` Ben Elliston
  0 siblings, 0 replies; 5+ messages in thread
From: Ben Elliston @ 2002-12-19 14:12 UTC (permalink / raw)
  To: David Carney; +Cc: cgen

Hi David,

>>>>> "David" == David Carney <dfcarney@net-itech.com> writes:

  David> So, basically, I define my own .cpu file and add a new target
  David> to the binutils/opcodes Makefile (that'll use cgen in
  David> conjunction with my .cpu file), correct?  After I get cgen to
  David> properly generate files for binutils/opcodes, I'll need to
  David> write my own cpu-???.* and elf32-???.* files for the
  David> binutils/bfd, right?

Yes.  There is relatively little work to do here (a few hundred lines
of C code).  You can start with an existing port and clone it.  Once
you get it working, you'll understand it much better and can go back
and clean it up.

  David> What else will I need to do to get an assembler up and
  David> running?

You'll need to write the appropriate gas/config/* files (ie. port
GAS).  This is mostly simplified, with a few #defines to set and some
stub functions that mostly call into cgen's "binutils" runtime
functions in opcodes and gas.

I'd strongly recommend you follow a CGEN-based gas/binutils port
closely for guidance once you get to that stage.

Good luck!

Ben

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-12-19 22:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-18 15:23 cgen fundamentals David Carney
2002-12-18 17:31 ` Ben Elliston
2002-12-19 11:34   ` David Carney
2002-12-19 14:12     ` Ben Elliston
2002-12-19  4:51 ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).