Page 1 of 1
C compilers for 65816
Posted: Fri Jul 03, 2020 12:51 am
by JustClaire
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
Re: C compilers for 65816
Posted: Fri Jul 03, 2020 5:31 am
by BigEd
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.
Re: C compilers for 65816
Posted: Fri Jul 03, 2020 9:23 am
by BitWise
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.
Re: C compilers for 65816
Posted: Fri Jul 03, 2020 1:15 pm
by drogon
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
Re: C compilers for 65816
Posted: Fri Jul 03, 2020 3:54 pm
by BitWise
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.