6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 4:11 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: C compilers for 65816
PostPosted: Fri Jul 03, 2020 12:51 am 
Offline

Joined: Thu Feb 27, 2020 9:15 am
Posts: 18
Hello

This is the topic that have probably been touched 1000 times before, but here i am, bringing it up again.

What good C compilers for 816 are there? To be good it needs to work(obviously) and produce efficient enough code(after all we dont have gigabytes of memory space to work with).

I've heard that the WDC compiler is not the best option and also have seen some other compilers that have been either abandoned or dont support 816 fully and/or are heavily targeted towards a specific 6502 system(c64, apple2, nes, etc.) so i am pretty confused what are currently the best options for compilers.

EDIT:
Just to clarify, by "heavily targeted" i meant when a compiler supports 6502 with all the popular target platforms and some (sometimes semi-working) support for 816 on the side


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 03, 2020 5:31 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
I've a feeling that WDC's offering might be the best option, by being the only one. But it would be good to hear that this is not so.

The '02 is, it seems, not a great match(*) for C. It feels like it should be that the '816 is a better match, but then I'm not an expert on compilers. I have found that the '816 is quite a peculiar beast and takes a bit of getting used to, and I would think it could only be well-targeted by someone who had got to know it quite well.

Perhaps the SNES and the IIGS are the places to look?

(*) Not a terrible match either: the few HP calculators built on 6502-like micros were, I believe, written in C, and were successful enough. If the output of the compiler is good enough, it doesn't matter too much that it's not as good as hand-crafted code. It might help also if the C in question is written with sympathy for the machine it will execute on.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 03, 2020 9:23 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
WDC's 816 compiler generates OK code and unlike the 65C02 compiler does not crash when encountering an error.

The free copy doesn't include the assembler source for the startup module but you can get the code you need from this project.

https://github.com/andrew-jacobs/w65c816sxb-cdemo.

Try to avoid using stdio.h functions if you want a small program.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 03, 2020 1:15 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
BitWise wrote:
WDC's 816 compiler generates OK code and unlike the 65C02 compiler does not crash when encountering an error.

The free copy doesn't include the assembler source for the startup module but you can get the code you need from this project.

https://github.com/andrew-jacobs/w65c816sxb-cdemo.

Try to avoid using stdio.h functions if you want a small program.


Although I've now completely moved away from C on the '816 there is a small task I'm looking at where C may be better than the BCPL I'm currently using, but the question I have is; Does it provide some sort of loader to help move code segments into the correct banks before program startup, or is this what the startup module is for?

Thanks,

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 03, 2020 3:54 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
drogon wrote:
BitWise wrote:
WDC's 816 compiler generates OK code and unlike the 65C02 compiler does not crash when encountering an error.

The free copy doesn't include the assembler source for the startup module but you can get the code you need from this project.

https://github.com/andrew-jacobs/w65c816sxb-cdemo.

Try to avoid using stdio.h functions if you want a small program.


Although I've now completely moved away from C on the '816 there is a small task I'm looking at where C may be better than the BCPL I'm currently using, but the question I have is; Does it provide some sort of loader to help move code segments into the correct banks before program startup, or is this what the startup module is for?

Thanks,

-Gordon

I've not tried it but the linker supports building a image that contains relocatable code/data that is built for a different area (-C18000,8000 => link as if at $01:8000 but place at $00:8000 -- same for data with -Dxxxx,yyyy). You'd have to a write a custom startup module to use the addresses provided by the linker (during linking) to create a lda #/ldx #/ldy #/mvn code sequence that relocates code and the same for initialised data.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 29 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: