A new well-known compiler

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
User avatar
polluks
Officer Cadet
Posts: 52
Joined: Tue Jun 05, 2012 10:09 pm
Location: Germany
Contact:

A new well-known compiler

Post by polluks » Sat Apr 26, 2014 6:37 pm

cc65 development
Oric Atmos + Cumulus
Acorn Electron

User avatar
Dbug
Site Admin
Posts: 2304
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: A new well-known compiler

Post by Dbug » Sat Apr 26, 2014 8:35 pm

If somebody feels like reviewing the code generation quality (size, performance) compared to the current C compiler of the OSDK, you are welcome :)

Godzil
Squad Leader
Posts: 748
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: A new well-known compiler

Post by Godzil » Sun Apr 27, 2014 1:52 am

I don't think it could be good, GCC had never been made for 16bit and 8bit CPU.. It is bad on managing registers (it was top x86 centric) and the use of register on the 6502 is not really simple and standard, and as the 6502 have a really small stack, either we make a software stack (that use lot of memory, else:. Don't best too much function call or strange thing may happen :S

User avatar
ibisum
Squad Leader
Posts: 839
Joined: Fri Apr 03, 2009 8:56 am

Re: A new well-known compiler

Post by ibisum » Sun Apr 27, 2014 6:23 pm

I'd love to have a decent C compiler on the Oric - maybe something that can really exploit the new-found power of Cumulus, perhaps, to give the Oric at least a decent way of building optimized apps in a language other than Basic, without requiring the investment into an archaic assembly language. That is to say, if we had a good C compiler *on* the Oric, assuming you have a Cumulus/disk-space, then we can at least continue to see the Oric as a way to learn a language that has some relevance here today .. C is still a great language to learn, and the limits of the Oric platform are precisely the realms that C was designed to conquer, in the first place. Putting a decent C compiler on the Oric would help fulfill that dream ..

User avatar
Dbug
Site Admin
Posts: 2304
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: A new well-known compiler

Post by Dbug » Sun Apr 27, 2014 9:21 pm

ibisum wrote:I'd love to have a decent C compiler on the Oric - maybe something that can really exploit the new-found power of Cumulus, perhaps, to give the Oric at least a decent way of building optimized apps in a language other than Basic, without requiring the investment into an archaic assembly language. That is to say, if we had a good C compiler *on* the Oric, assuming you have a Cumulus/disk-space, then we can at least continue to see the Oric as a way to learn a language that has some relevance here today .. C is still a great language to learn, and the limits of the Oric platform are precisely the realms that C was designed to conquer, in the first place. Putting a decent C compiler on the Oric would help fulfill that dream ..
Calling indecent the C compiler we have at the moment is not really fair.

Sure it's not a record breaking performer, but it's pretty standard compliant, most code runs without any modification, it does not have any insane limitation either.

It definitely is good enough for somebody who wants to learn C.

User avatar
ibisum
Squad Leader
Posts: 839
Joined: Fri Apr 03, 2009 8:56 am

Re: A new well-known compiler

Post by ibisum » Mon Apr 28, 2014 8:19 am

Well - correct me if I'm wrong, but aren't you talking about a Cross-compiler? I'm sure we can find tons of decent C compilers to cross-compile - but what I would find very productive for teaching my kids C is if they didn't need another machine to cross-compile, but could instead use the Oric itself ..

Anyway, I'm not complaining - just making a desire for the future. If the Cumulus Age can give us more onboard tools now we have near-infinite space available, then I think an onboard C compiler would be great.

Godzil
Squad Leader
Posts: 748
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: A new well-known compiler

Post by Godzil » Mon Apr 28, 2014 9:03 am

A C compiler running on the oric is almost impossible to do, at least to have good conformance with the C standard. For example on TI 68k calculator the only C compiler existing take more than the 64K limit with a fairly poor C89 conformance and the 68000 inside is much powerful than the 6502 running the oric, and takes ages just to compile even simple applications..

Impossible is maybe I bit harsh, but running a c compiler without an OS have no meaning so we need sedoric or other DOS, a floppy drive and with such setup the memory is extremely limited..

CrossCompiling for he Oric and all 6502 based computer is almost the only way to go. The only C compiler running on a CPU of the 65cxx family was on the IIGS which have a 65c816 and the compiler have lost of limitation.. (And the 65c816 have access to larger memory space than the 6502)

If you really want your kids to practice C or over language on cheap/low power computer, you better search for a any 68000 computer or a beaglebone (black) a rPI or an Arduino (even if this one need a PC to cross compile)

User avatar
ibisum
Squad Leader
Posts: 839
Joined: Fri Apr 03, 2009 8:56 am

Re: A new well-known compiler

Post by ibisum » Mon Apr 28, 2014 12:25 pm

We already have plenty of other toys to learn C programming on. I just wanted something that would work on the Oric.

And, imho, doesn't the Cumulus represent a near-infinite amount of expansion when it comes to compiling? We don't have to build a single-pass compiler - multiple passes, given the RAM limits, might work.

Anyway this is all blue-sky thinking, and I suppose I should put more energy into actually contributing something to this aspect of Oric life ..

User avatar
Dbug
Site Admin
Posts: 2304
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: A new well-known compiler

Post by Dbug » Mon Apr 28, 2014 5:53 pm

ibisum wrote:We already have plenty of other toys to learn C programming on. I just wanted something that would work on the Oric.

And, imho, doesn't the Cumulus represent a near-infinite amount of expansion when it comes to compiling? We don't have to build a single-pass compiler - multiple passes, given the RAM limits, might work.

Anyway this is all blue-sky thinking, and I suppose I should put more energy into actually contributing something to this aspect of Oric life ..
You could try to port one of the existing C compilers on the Oric, using Cumulus and multi-pass as you said, or write your own.

Let's have a deal: If you can make a working C compiler that runs on the Oric and generate decent code, I promise to write an efficient text editor for it, complete with syntax coloring, shortcuts, and built-in documentation.

User avatar
Chema
Game master
Posts: 1941
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: A new well-known compiler

Post by Chema » Mon Apr 28, 2014 6:43 pm

Dbug wrote: Let's have a deal: If you can make a working C compiler that runs on the Oric and generate decent code, I promise to write an efficient text editor for it, complete with syntax coloring, shortcuts, and built-in documentation.
Sorry for the Off topic, but wouldn't it be on top of the wishlist a new revision of Cumulus firmware? I *really* think a better software could help some people out there with Orics which seem not to be compatible with it...

Not trying to stop anyone's dreams (hey, I am the first one doing my own things, instead of helping with this) but thought it would be nice to remember this need...

User avatar
iss
Flight Lieutenant
Posts: 447
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: A new well-known compiler

Post by iss » Thu May 01, 2014 5:48 pm

Does someone tried to compile GCC 6502?
By me it failed. Yes, I know this forum is not the right place to report GCC 6502 bugs,
but I think it would be interesting to discuss the error - just like assembler puzzle :).
The question is:
How can be replaced the expression in the C source, so the result remains correct and the compilation succeeded?

*OR* How to workaround the red lines:
....
lda _r0
sec
sbc #-$80
...

*OR* Is this equivalent to the above lines?
....
lda _r0
clc
adc #$7F
...

Here are the details (sorry, they are bit long):

Compilation stuck at the following error:

Code: Select all

/tmp/ccCO416X.s(82): Error: Range error (-128 not in [0..255])
The corresponding part of the C source is:

Code: Select all

UWtype
__fixunssfSI (SFtype a)
{
  if (a >= - (SFtype) Wtype_MIN)
    return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
  return (Wtype) a;
}
And the translated ASM source is:

Code: Select all

    .feature at_in_identifiers
    .feature dollar_in_identifiers
    .autoimport +
    .p02
    .importzp _sp0, _sp1, _fp0, _fp1
    .importzp _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7
    .importzp _s0, _s1, _s2, _s3, _s4, _s5, _s6, _s7
    .importzp _tmp0, _tmp1
    .segment "CODE"
    .export __fixunssfqi
__fixunssfqi:
; frame size 0, pretend size 0, outgoing size 0
    lda _s4
    pha
    lda _s3
    pha
    lda _s2
    pha
    lda _s1
    pha
    lda _s0
    pha
    lda _r0
    sta _s3
    lda _r1
    sta _s2
    lda _r2
    sta _s1
    lda _r3
    sta _s0
    lda #$86
    sta _s4
    lda #$00
    sta _r4
    sta _r5
    sta _r6
    lda _s4
    sta _r7
    jsr __gesf2
    lda _r0
    cmp #$00
    bne L@8
    lda _s3
    sta _r0
    lda _s2
    sta _r1
    lda _s1
    sta _r2
    lda _s0
    sta _r3
    jsr __fixsfsi
    pla
    sta _s0
    pla
    sta _s1
    pla
    sta _s2
    pla
    sta _s3
    pla
    sta _s4
    rts
L@8:
    lda _s3
    sta _r0
    lda _s2
    sta _r1
    lda _s1
    sta _r2
    lda _s0
    sta _r3
    lda #$00
    sta _r4
    sta _r5
    sta _r6
    lda _s4
    sta _r7
    jsr __subsf3
    jsr __fixsfsi
    lda _r0
    sec
    sbc #-$80
    sta _r0
    pla
    sta _s0
    pla
    sta _s1
    pla
    sta _s2
    pla
    sta _s3
    pla
    sta _s4
    rts
The same happens at other places too:

Code: Select all

L@182:
    lda _s2
    sec
    sbc #-$fe
    sta _s2
    txa
    clc
    adc _s0
    tax
    jmp L@41

/tmp/ccouptBF.s(1253): Error: Range error (-254 not in [0..255])

Godzil
Squad Leader
Posts: 748
Joined: Sat May 21, 2011 7:21 pm
Location: Between UK and France
Contact:

Re: A new well-known compiler

Post by Godzil » Thu May 01, 2014 7:40 pm

The problem is the assembly itself that should not presume of the "type" and accept either -128/+127 or 0/255 values.

JamesD
Flight Lieutenant
Posts: 352
Joined: Tue Nov 07, 2006 7:38 am

Re: A new well-known compiler

Post by JamesD » Fri May 09, 2014 5:26 am

If I remember correctly, the 6502 version of GCC was based on an old version of GCC and didn't have all the bugs fully worked out.
The version of GCC used is now so old and GCC has changed so much that it would be difficult to port the 6502 code generator to the newer code tree.

User avatar
iss
Flight Lieutenant
Posts: 447
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: A new well-known compiler

Post by iss » Fri May 09, 2014 9:01 pm

Yes, you remember correctly about the 6502 GCC port based on ver. 2.x.x.

But the above link points to a newer port: "gcc version 4.9.0 20140404 (experimental) (GCC)"
The maintainer is very responsive - I reported the bug and it's fixed in just a week !

For now I don't have any impressions of this new compiler,
but I'm really curious to run some checks.

User avatar
Dbug
Site Admin
Posts: 2304
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: A new well-known compiler

Post by Dbug » Fri May 09, 2014 10:59 pm

iss wrote:For now I don't have any impressions of this new compiler,
but I'm really curious to run some checks.
Would be interesting to write a small test:

- Use the internal timer to get some accurate values, and then use it to time some routines, both with the old compiler and the new one
- Measure the size of the executable

Things easy to measure are for example:
- Loop in C to erase the screen or copy a picture
- Things like computing factorials or digits of pi
- Efficiency of complicated code with multiple loops, calling functions with parameters that themselves do stuff
- Recursion (limited)
- How it handles 8 bits and 16 bit values

Also, an important factor is how easy it is to integrate with an external assembler. GAS is a piece of turd, GCC inline assemble has been designed by retarded psychopaths and should not be used even under duress, so it's important to be able to mix and match with other assemblers :)

Feel free to test and report findings :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest