Looking for programming languages that compile to C

The GNU Ada compiler, GNAT. See

formatting link
There is a GNAT version targeting 8-bit AVRs, but not the Z80, I believe. A free version of the AVR Ada compiler is at
formatting link
but I think it supports a subset of Ada, not the full language.

There is also an Ada-to-C compiler, see

formatting link
but it is not free.

--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .
Reply to
Niklas Holsti
Loading thread data ...

Jon Kirwan schrieb:

I want to write programs for a Z80-based system where 32K of RAM and 32 K of ROM are available, developing on and cross-compiling on a GNU/Linux system. So far I've used the sdcc compiler for this. Now I'm looking for something that compiles to C; the output would then be fed into sdcc again. I would like to be able to use the C libraries I have written for this system before. My goal is both to try a new language (I know C, but would like to have a look at other programming styles, maybe OO or functional) and see how sdcc handles the resulting C code.

Unfortunately AFAIK, no one has managed to build cfront on a modern system (googling e.g. for cfront linux doesn't return any encouraging results).

Philipp

Reply to
Philipp Klaus Krause

-jg schrieb:

and 32KB of ROM. :)

I intend to develop on a modern GNU/Linux system, and use the sdcc cross-compiler to generate binaries for the Z80 system from C.

Philipp

Reply to
Philipp Klaus Krause

Hopefully, someone "in the know" on cfront implementations will say something, then. It definitely was a "product" for a while. I'd hope, but can only hope for now, that those who worked on it and the company that paid for that time and effort and owns the result (AT&T?) has made it available in some fashion so that it can continue. It's possible, however, that it has been deep-sixed in order to make absolutely sure that a separate development path didn't interfere with c++'s "intended" track. So maybe it does NOT exist in a usable form, anymore. I'd be a bit sad about that, if so.

Jon

Reply to
Jon Kirwan

Tim Wescott schrieb:

It's C. It's the language I use most and know best, but I think it would be good to try something different, have a look at other programming langauages and how things are done in those langauages even if in the end C will probably remain the language I use most.

Philipp

Reply to
Philipp Klaus Krause

and 32KB of ROM. :)

Forget it - you cannot squeeze even a Linux kernel into a Z80, even with a shoehorn.

--

Tauno Voipio
Reply to
Tauno Voipio

Zilog also have a C compiler.

What Debug solution do you use ?

This website

formatting link
says ["If you cannot avoid C, use o2c, its successor OOC, or Ofront to convert Oberon to C."] - so there are some C pathways.

and this is low cost, and supports Z80 and Rabbit

formatting link
Pascal Z180 area

-jg

Reply to
-jg

Sorry, my post was probably a bit confusing (English isn't my native tongue): The modern GNU/Linux is my development platform. The Whatever-to-C translator and the C cross-compiler (sdcc) run there. The resulting binary is to be burnt into an EPROM and run on the target Z80 system. I do not intend to run FNU/Linux, the Whatever-to-C translator or the cross-compiler on the Z80.

Philipp

Reply to
Philipp Klaus Krause

If that's what you are looking for, then I strongly recommend changing platforms. Move to something like an ARM, or any other well-supported

32-bit architecture, and you will have a very much easier time experimenting and learning. Once you have something that has good gcc support, you've got C, C++, Ada, Objective C, Fortran, Pascal, Forth, and D ready to try (libraries and debugging might be issues). You also have enough power to use scripting languages like Lua.

The Z80 was a nice architecture in its time - but that time was about 20 years ago.

Reply to
David Brown

He means using Linux as the host, not as a target OS.

Reply to
David Brown

A couple that spring to mind are smart-eiffel (for the object oriented flavour), gambit-C (for scheme/functional) and there's at least one forth that compiles through C, from memory. Unfortunately, I suspect that all of those will probably have some fairly strong assumptions about 32- bitness that will be uncomfortable to accommodate on a Z-80.

For practical purposes, you're probably better off getting your higher- level ease through an interpreter (that you might have to write yourself), and which links to your existing C libraries. There are some pretty cool starting points in VM-based scheme and threaded forth systems.

The tricky part is going to be building a sufficiently sophisticated garbage collection system that will run in that little memory: most of the "cool" languages use garbage collection. A simple mark/sweep engine might do for starters. A multi-generational BIBOP allocator might not fit comfortably...

Cheers,

--
Andrew
Reply to
Andrew Reilly

When I worked on the Z80 ( 80's) there was the Aztec c-compiler. It was a nice system, well-documented, with source for the libraries. It wasn't free, but almost (couple of hundred euro's). If you can lay hands on a copy, it will certainly full fill your needs.

At the time having merely 1KB of RAM wasn't extreme.

--

--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Reply to
Albert van der Horst

Albert van der Horst schrieb:

I'm not looking for a C compiler. There already is sdcc targeting the Z80, which seems perfect for me. I want to try different languages, which should compile to C (so I can send the resulting C code into sdcc).

Philipp

Reply to
Philipp Klaus Krause

cfront is a historical curiosity. It never kept up with the standard, so only the most basic C++ code would even compile. The historic code I played around with seems to be in a rather poor state for cross-compatibility as well.

Reply to
Doug McIntyre

Do you have any objection to compilers which generate binary directly? If you have a link map from SDCC it is usually quite simple to provide an interface to the C libraries, providing that you know the start up mechanism of the C system.

Stephen

--
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads
Reply to
Stephen Pelc

There are a couple of Oberon to C compilers in existence. e.g. Ofront.

  1. It compiles to C
  2. It is free for non-commercial use
  3. There aren't too many practical high-level languages that are more compact than Oberon.

Versions are available for Linux and Windows:

formatting link

If that doesn't meet your requirements if I were you I'd follow others' recommendations and:

a) switch from the Z80 to an ARM processor b) forget about using C as an intermediate language

-- Chris Burrows CFB Software Armaide: ARM Oberon-07 Development System

formatting link

Reply to
Chris Burrows

Then may I be so bold as to suggest:

You may be going about this the wrong way. Go ahead and learn some of those other languages on your development platform. There are awide variety of compilers for LINUX. Once you decide on one you like and that seems to fit your target platform (Z80) needs, then write the compiler yourself. Trust me, if you really want to learn programming techniques, writing a compiler will teach you a LOT.

HTH, ed

Reply to
Ed Prochak

Stephen Pelc schrieb:

Well, another motivation for wanting languages that compile to C is that I want to see how well sdcc handles automatically generated code. I.e. it could help discover sdcc bugs and improve sdcc's quality. In the past this has already been the case with nesC (a programming language to be used with TinyOS for wireless sensor networks that compiles to C).

Philipp

Reply to
Philipp Klaus Krause

Unfortunately some projects using llvm seem to have no support for the C backend (I just looked at the ldc D compiler so far).

Philipp

Reply to
Philipp Klaus Krause

10 years ago, oops 15 years ago, we had something called Mocca (IIRC) at university which compiled Modula-2 to C, but so far I did not find it on the internet.
--
42Bastian
Do not email to bastian42@yahoo.com, it's a spam-only account :-)
Use @monlynx.de instead !
Reply to
42Bastian Schick

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.