C compiler
C compiler
In my former life I used to write software for a large telecomunications company, mainly in C and Oracle, with a bit of java, c++, and laterley VBA and .net thrown in.
Wanting to keep the little grey cells active and get back into it, I have been looking around the interwebs and there seem to be a number of C compilers around for the 6502 and the beeb specifically. The favourite seems to be "Small-C compiler for the BBC Micro", but people running Linux swear by (or at) 4corn cc65 anyone with experiance/wise words?
Wanting to keep the little grey cells active and get back into it, I have been looking around the interwebs and there seem to be a number of C compilers around for the 6502 and the beeb specifically. The favourite seems to be "Small-C compiler for the BBC Micro", but people running Linux swear by (or at) 4corn cc65 anyone with experiance/wise words?
Ashley.
Re: C compiler
I use itzor's gcc port (latest is gcc8). It kinda needs some backend work to be truely useful as the pointer dereferencing in particular produces some terribly clunky code. He hasn't touched the repo on githhub for a couple of years now though
I have looked at the backend but they are flipping complicated. It isn't something you can tinker with unless you're very much up to speed on that stuff. I've also considered making it more BBC friendly with runtime library ROMs but lack a motivating project to kickstart me into action.
I have looked at the backend but they are flipping complicated. It isn't something you can tinker with unless you're very much up to speed on that stuff. I've also considered making it more BBC friendly with runtime library ROMs but lack a motivating project to kickstart me into action.
Re: C compiler
I'm pretty sure http://www.pouet.net/ uses a C cross-compiler with gcc frontend and maybe cc65 backend.
Flibble on here is using some gcc+? (probably cc65 again) C cross-compiler to write a Final Fantasy like game in C.
I think it is the backend, optionally plus a ROM, that is really needed to make C a general purpose language on the beeb.
I also think that it shouldn't be a cut down C unless you are planning on doing the compiling on the beeb.
Having said that, lots of projects here are not general purpose, but the authors still enjoy themselves creating them.
You might find this interesting: https://dwheeler.com/6502/.
I have had a few goes at writing a C cross-compiler for the beeb, but always end up creating a new C like language and then never getting anywhere on the compiler.
In general, if it is a cross-compiler, why stop at C, why not support C++ (C++98 would be fine for me ?)
Flibble on here is using some gcc+? (probably cc65 again) C cross-compiler to write a Final Fantasy like game in C.
I think it is the backend, optionally plus a ROM, that is really needed to make C a general purpose language on the beeb.
I also think that it shouldn't be a cut down C unless you are planning on doing the compiling on the beeb.
Having said that, lots of projects here are not general purpose, but the authors still enjoy themselves creating them.
You might find this interesting: https://dwheeler.com/6502/.
I have had a few goes at writing a C cross-compiler for the beeb, but always end up creating a new C like language and then never getting anywhere on the compiler.
In general, if it is a cross-compiler, why stop at C, why not support C++ (C++98 would be fine for me ?)
- Lardo Boffin
- Posts: 2977
- Joined: Thu Aug 06, 2015 7:47 am
- Contact:
Re: C compiler
Probably a little off topic but I used the Norcroft C compiler on the Arm Co-processor (raspberry Pi, not original sadly) and then used Twin as the text editor. All run directly on my Master.
It produces native ARM code I believe.
It produces native ARM code I believe.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
Re: C compiler
I'm using the Itzor branch of gcc (not cc65) that cmorley mentioned above, I wrote some instructions and helper library stuff you can find here.
http://www.4corn.co.uk/articles/gccforbbc/
Re: C compiler
Anyone tried getting this to work recently?flibble wrote: ↑Sat Jan 23, 2021 8:02 pmI'm using the Itzor branch of gcc (not cc65) that cmorley mentioned above, I wrote some instructions and helper library stuff you can find here.
http://www.4corn.co.uk/articles/gccforbbc/
I tried pulling it, following the instructions, and it was all going swimmingly, until I got to:
Code: Select all
git clone --recursive https://github.com/itszor/gcc-6502-bits.git
It exited with:
I pulled the zip of a gcc-src directory from the history, and managed to get the first stage of build.sh to run (having corrected permissions), but it failed on the second stage..fatal: clone of 'http://www.github.com/itszor/gcc-6502' into submodule path '/home/rgodi/gcc-6502-bits/gcc-src' failed
Failed to clone 'gcc-src' a second time, aborting
Code: Select all
config.status: executing default commands
make[1]: Leaving directory '/home/rgodi/gcc-6502-bits/gcc-build'
make: *** [Makefile:883: all] Error 2
Re: C compiler
Which version of Norcroft you used? The one from the RISCOS DDE?Lardo Boffin wrote: ↑Sat Jan 23, 2021 6:34 pm Probably a little off topic but I used the Norcroft C compiler on the Arm Co-processor (raspberry Pi, not original sadly) and then used Twin as the text editor. All run directly on my Master.
It produces native ARM code I believe.
>>>>>>>>>>>Lets go
- Lardo Boffin
- Posts: 2977
- Joined: Thu Aug 06, 2015 7:47 am
- Contact:
Re: C compiler
I’m not sure to be honest. The disc image was provided by someone on here. I will have to have a look back and see.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
Re: C compiler
If you could provide the image, that would be great. I’m a registered DDE developer, so licensing should be no issue.
>>>>>>>>>>>Lets go
-
- Posts: 215
- Joined: Tue Jul 03, 2007 10:40 am
- Location: italy
- Contact:
Re: C compiler
In case anyone would be interested, SDCC (Small Devices C Compiler) latest version emits code for 65XX processors. I have not given a full turn to the compiler, just a few snippets here and there and the generated code is at least at cc65 level (maybe a little better but cannot swear for it).
- gordonDrogon
- Posts: 94
- Joined: Fri Nov 23, 2018 12:39 pm
- Location: Scottish Borders
- Contact:
Re: C compiler
C seems to be a holy grail of sorts for older systems - the 6502 being no exception.
My own ventures were aimed at making a 6502 SCB "self hosting" - so making it run the languages natively rather than cross compiling.. Basic was easy but when it came to C... Harder. I did use Aztec C on the Apple II before my Beeb exposure but early on, C for the Beeb? Not really and I ended up doing a big (university) Industrial control/Factory automation project on an Econeted network of many Beebs in BCPL, but that's a story for another day...
Latterly I made a 6502 SBC that is vaguely Acorn MOS compatible and created a port of cc65 for it with a target and startup/run time library that let me compile C as a "language ROM" and run it on my SBC. I never tried it on a real Beeb though.
I could refresh that project but ...
The biggest thing I write in C for it was a port of my small editor (a nano-like thing written in C) - it's about 1500 lines of code and whitespace and compiles to some 14KB of 6502, so fits inside a sideways ROM and worked very well.
Downsides - no floating point and having to cross compile under Linux.
I changed tack somewhat a few years back and moved to something else where I could compile and run directly on my SBC and haven't looked back at C (on the 6502) since.
There are a few other C compilers for the 6502 now - VBCC and Calypsi
http://www.compilers.de/vbcc.html
https://www.calypsi.cc/
There is also work on-going on LLVM
https://llvm-mos.org/wiki/Welcome
I wonder if someone could write a C to BBC Basic translator...
-Gordon
My own ventures were aimed at making a 6502 SCB "self hosting" - so making it run the languages natively rather than cross compiling.. Basic was easy but when it came to C... Harder. I did use Aztec C on the Apple II before my Beeb exposure but early on, C for the Beeb? Not really and I ended up doing a big (university) Industrial control/Factory automation project on an Econeted network of many Beebs in BCPL, but that's a story for another day...
Latterly I made a 6502 SBC that is vaguely Acorn MOS compatible and created a port of cc65 for it with a target and startup/run time library that let me compile C as a "language ROM" and run it on my SBC. I never tried it on a real Beeb though.
I could refresh that project but ...
The biggest thing I write in C for it was a port of my small editor (a nano-like thing written in C) - it's about 1500 lines of code and whitespace and compiles to some 14KB of 6502, so fits inside a sideways ROM and worked very well.
Downsides - no floating point and having to cross compile under Linux.
I changed tack somewhat a few years back and moved to something else where I could compile and run directly on my SBC and haven't looked back at C (on the 6502) since.
There are a few other C compilers for the 6502 now - VBCC and Calypsi
http://www.compilers.de/vbcc.html
https://www.calypsi.cc/
There is also work on-going on LLVM
https://llvm-mos.org/wiki/Welcome
I wonder if someone could write a C to BBC Basic translator...
-Gordon
- Lardo Boffin
- Posts: 2977
- Joined: Thu Aug 06, 2015 7:47 am
- Contact:
Re: C compiler
I will do but I need to remember who I got the original files from, ask them if I can pass them on and then extract them onto an image.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA