Page 3 of 3

Re: C02 - An 8-bit optimized C syntax compiler for the 6502

Posted: Fri Mar 16, 2018 11:03 pm
by unclouded
Just an idea: How about maintaining a short piece of sample code so we can see the current syntax? I like the way http://coffeescript.org/ explains the language by example.

Re: C02 - An 8-bit optimized C syntax compiler for the 6502

Posted: Sat Mar 17, 2018 8:21 pm
by CurtisP
unclouded wrote:
Just an idea: How about maintaining a short piece of sample code so we can see the current syntax? I like the way http://coffeescript.org/ explains the language by example.
A dense, but fairly exhaustive sample code section has been added to the README file, along with the new logo designed by Triangular

Re: C02 - An 8-bit optimized C syntax compiler for the 6502

Posted: Mon Mar 19, 2018 8:03 am
by unclouded
CurtisP wrote:
A dense, but fairly exhaustive sample code section has been added to the README file
Very nice! Is this one correct?

Code: Select all

do (c = getchr(); putchr(c); while (c<>13)
It looks to the untrained eye like there's an unmatched parenthesis following `do`

I see that:

Code: Select all

i:+
..is a condition for "i is positive". It might be friendlier to just recognise

Code: Select all

i>=0
as a degenerate comparison and emit the `BMI` pattern.

Re: C02 - An 8-bit optimized C syntax compiler for the 6502

Posted: Mon Mar 19, 2018 7:59 pm
by CurtisP
unclouded wrote:
Is this one correct?

Code: Select all

do (c = getchr(); putchr(c); while (c<>13)
It looks to the untrained eye like there's an unmatched parenthesis following `do`
This should have been

Code: Select all

do {c = getchr(); putchr(c);} while (c<>13)
I'll fix it.
unclouded wrote:
I see that:

Code: Select all

i:+
..is a condition for "i is positive". It might be friendlier to just recognise

Code: Select all

i>=0
as a degenerate comparison and emit the `BMI` pattern.
That won't work, because all variables, expressions, and comparisons are unsigned. So (128 > 1) is true even though (128:+) is not, and (128>0) should work the same way.

Re: C02 - An 8-bit optimized C syntax compiler for the 6502

Posted: Thu Jul 19, 2018 4:40 am
by CurtisP
After a few months hiatus, I've started working on C02. I fixes a bug with break & continue in do/while loops, add a tag for strings to printf() in library stdiox.

I also added a new library memio, which mimics file i/o functions, but reads and writes directly to memory, for use with machines and emulators that do not have file system support, but do support loading and saving blocks of memory to and from a storage device. I did this to allow development of programs that would normally interact with files on these systems.

Re: C02 - An 8-bit optimized C syntax compiler for the 6502

Posted: Fri Jul 20, 2018 6:58 pm
by CurtisP
I fixed a bug in the parsing of escape sequences in strings (dumb mistake, but took me a while to find it).

But more importantly I made two changes to expression parsing and compilation: Expressions may be used as indexes in any subscripted array references within expressions, and function calls may appear in any term of an expression

My next step is to allow expressions as the second (and possibly third) arguments of function calls. I figure the less quirks in the language specification the better.

All changes have been pushed up to the github repository at https://github.com/RevCurtisP/C02

Re: C02 - An 8-bit optimized C syntax compiler for the 6502

Posted: Thu Jul 23, 2020 5:15 pm
by BigEd
Just to note, I stumbled on this old thread, and am pleased to see active development still going on in the repository. Nice!