Page 1 of 2

A C compiler that can compile for dragon 32?

Posted: Fri May 05, 2017 9:57 pm
by lukeoftheaura
Hi,
is there a C compiler available (for linux preferably) that can compile for the dragon 32?

Thanks,
luke

Re: A C compiler that can compile for dragon 32?

Posted: Fri May 05, 2017 10:17 pm
by robcfg
Hi Luke!

Maybe gcc 6809 is what you're looking for.

Cheers,
Rob

Re: A C compiler that can compile for dragon 32?

Posted: Sat May 06, 2017 10:01 am
by Bosco
Also, Pierre Sarrazin has developed a 6809-generating cross-compiler for a subset of the C language.

http://perso.b2b2c.ca/~sarrazip/dev/cmoc.html

The website says `The most significant difference between CMOC and a complete C compiler is the absence of longs and floats and of the const keyword.'

I'm not very knowledgable about such things but thought I'd post a link in case it was of interest? :)

Re: A C compiler that can compile for dragon 32?

Posted: Sat May 06, 2017 12:14 pm
by robcfg
Of course it's of interest!

I've tried a couple of times to compile gcc6809 without luck, so maybe this one will come in handy.

Thanks, mate!

Re: A C compiler that can compile for dragon 32?

Posted: Sat May 06, 2017 2:23 pm
by lukeoftheaura
Bosco wrote:Also, Pierre Sarrazin has developed a 6809-generating cross-compiler for a subset of the C language.

http://perso.b2b2c.ca/~sarrazip/dev/cmoc.html

The website says `The most significant difference between CMOC and a complete C compiler is the absence of longs and floats and of the const keyword.'

I'm not very knowledgable about such things but thought I'd post a link in case it was of interest? :)
I'll certainly give this a look - compiling gcc6809 seems like a bit of a pain.I wonder if there's a graphics library?

Re: A C compiler that can compile for dragon 32?

Posted: Sat May 06, 2017 2:30 pm
by Bosco
I know CMOC supports inline assembly language. Handy I guess for sections of code which are speed critical.

I think Rick Adams wrote `Temple of Rom' using a mix of C and ASM?

Re: A C compiler that can compile for dragon 32?

Posted: Sat May 06, 2017 2:50 pm
by lukeoftheaura
So far I've managed to write the classic "Hello world" program using CMOC and run it on xroar and I'm quite impressed, but I don't know how to then convert that so I can run it on real hardware (to cas or WAV). any ideas?

Re: A C compiler that can compile for dragon 32?

Posted: Sat May 06, 2017 3:44 pm
by Bosco

Re: A C compiler that can compile for dragon 32?

Posted: Sat May 06, 2017 8:22 pm
by lukeoftheaura
I can't seem to make bin2cas work, there's probably an option I'm missing.
I have this program:

Code: Select all

#include <cmoc.h>
int main()
{
    printf("HELLO WORLD!\n");
    return 0;
}
I compile it using

Code: Select all

cmoc main.c
and when I open the bin with xroar, I get the expected output. Then, I run bin2cas to convert to a cas file, and cas2wav to convert to cas:

Code: Select all

./bin2cas.pl main.bin -omain.cas
./cas2wav main.cas main.wav
Then when I open the wav or the cas in xroar it seems to load the file but then nothing happens (it stays on the screen saying "F MAIN"), and I get the same response when I load it on my dragon 32.

Re: A C compiler that can compile for dragon 32?

Posted: Sat May 06, 2017 9:56 pm
by robcfg
Hi Luke,

Try my DrBinCas program which you can find here.

Tell me if you have any problem with it.