6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed Jun 26, 2024 3:52 am

All times are UTC




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Mon Feb 05, 2018 2:46 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
I just realized that the 65C02's PLX instruction gives me a way to easily allow an expression to be use as an array index on the left side of the assignment.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 05, 2018 3:34 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
I created a branch that targets the 65C02. but couldn't get the code to compile in dasm.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 05, 2018 4:11 am 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
CurtisP wrote:
The intention of the language is that the fiddly parts will be written in assembler and called as functions. And the general program flow and overall logic written in C02.

That makes perfect sense. It means the compiler can be simpler, and you don't have to worry about including something that could potentially be sub-optimal.

CurtisP wrote:
The name was intended to be a pun of CO₂ (Carbon Dioxide), and I was also considering a variant for the 8080/Z80 called C80.

At the very least I should rename the compiler cc02, to match cc, gcc, tcc, etc...


Funnily enough, I was wondering if this would translate well to the z80...
The CO₂ pun idea was actually fairly good, I think. I don't know about the whole cc thing, though.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 05, 2018 9:28 pm 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
DerTrueForce wrote:
I still think I'd like to use C02 in my project, especially if it runs on the 'C02 as well.


What platforms will you be writing 6502 code for and on?


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 05, 2018 9:51 pm 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 672
By the way, comparing to cc65 isn't going to be that meaningful. CC65's goal is to bring actual proper standard C to 6502 platforms, so it's going to be bigger and have greater mismatch with the CPU platform assumptions. If C02's goal is to have a 6502-friendly "C-like language", then yeah you're going to generate smaller more 6502-idiosyncratic instructions, but it's still a custom language to learn if you want to attract a userbase instead of just building your own tools.

_________________
WFDis Interactive 6502 Disassembler
AcheronVM: A Reconfigurable 16-bit Virtual CPU for the 6502 Microprocessor


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 05, 2018 9:57 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10834
Location: England
Sounds good to me though - a c-like language with a good fit to the machine.

(I'd call it CC02 though, to make search easier.)


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 06, 2018 12:58 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
White Flame wrote:
CC65's goal is to bring actual proper standard C to 6502 platforms, so it's going to be bigger and have greater mismatch with the CPU platform assumptions.


Then C02 fills a different niche, which is what I was going for.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 06, 2018 2:19 am 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
CurtisP wrote:
DerTrueForce wrote:
I still think I'd like to use C02 in my project, especially if it runs on the 'C02 as well.


What platforms will you be writing 6502 code for and on?

The project I'm referring to is going to be a handheld device(project thread here). One of my goals for it is to have it be able to build and overwrite it's own firmware and OS. I was originally going to do this by writing an assembler to run on it, and write the OS in assembly. If I can do that in something a little bit nicer, that'll make it much easier.
Basically, I'd want to use it on and for my own platform. This means I'd need to write my own libraries for it or adapt existing ones, but I think I can do that.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 26, 2018 3:07 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
I added a command line option -h to specify a header file to be inserted at the beginning of the code.

The purpose is to allow a single program to be easily compiled against different target machines.

I plan to add another option to specify the include file directory and restructure the sample/test code directories to better demostrate how this can be used.


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 01, 2018 8:31 am 
Offline

Joined: Tue Feb 24, 2015 11:07 pm
Posts: 81
White Flame wrote:
By the way, comparing to cc65 isn't going to be that meaningful. CC65's goal is to bring actual proper standard C to 6502 platforms, so it's going to be bigger and have greater mismatch with the CPU platform assumptions. If C02's goal is to have a 6502-friendly "C-like language", then yeah you're going to generate smaller more 6502-idiosyncratic instructions, but it's still a custom language to learn if you want to attract a userbase instead of just building your own tools.

I agree, the comparison isn't fair since cc65 can compile C never intended for the 6502. Perhaps a comparison with https://github.com/dschmenk/PLASMA, since it was designed for the 6502.

Having more high-level language compilers for the 6502 is a win though. I didn't use cc65 because it's C, I used it because I found it quicker for testing ideas than assembler. I'd be prepared to learn a new syntax for that purpose (and I'm jealous because I wanted to write a high level language closely bound to the 6502).


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 02, 2018 4:52 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
unclouded wrote:
White Flame wrote:
I'd be prepared to learn a new syntax for that purpose (and I'm jealous because I wanted to write a high level language closely bound to the 6502).


This has been stewing in my head for over a decade, and it wasn't until the last year that I really started implementing it.

I'm still working out the details so any and all suggestions are appreciated.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 02, 2018 4:59 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
Another update to the code: up to three variables on the left side of the assignment, for function calls that return values in the X and/or Y registers as well as the Accumulator.


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 07, 2018 5:18 pm 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
Another update:

I deprecated the #define directive in favor of the const keyword, although the syntax differs from standard C.

I had previously implemented an #enum directive. This has been replaced by the num keyword with a syntax similar to standard C.

All constant references in C02 are prefixed with a # symbol.


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 08, 2018 8:00 pm 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
Update: Added the struct keyword. C02 implements most of the functionality of structs in C.

Structs make the compiler a bit larger, but I feel they are too useful to leave out. For example, the variable and constant lookup tables are structured as arrjects (a separate array for each member). The struct lookup tables are implemented using structs and the as a result the code is much easier to read. I plan to go back and refactor the variable and constant tables to use structs as well.

C02 does not support arrays of structs, and the lack of native pointer support precludes a trivial implementation of linked lists. However, the block and pointer functions in the standard library were written to replicate both of these functionalities. The repository currently contains a test directory. I think I will add an examples directory as well.

Edit: I added @ as the size-of operator.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 16, 2018 3:53 am 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
Bug Fix: Chained IF/ELSE statements weren't compiling correctly. Finally figured out how to make them work.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 46 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: