Hello,
I have uploaded a new version of my C compiler for 6502 with experimental support for BBC Micro/Master computers to: http://www.compilers.de/vbcc.html
A few of the good things:
- compiler is under active development
- supports C99 (variable-length arrays, designated initializers etc.)
- generates optimized code (see dhrystones in sample directory)
- supports banked memory and far-pointers
- (limited) floating point support based on Steve Wozniaks code
- (pretty good) 32/64bit IEEE floating point support based on SANE
- support for 65C02 extensions
- support for writing interrupt handlers
- attributes for putting variables into zero page
- supports stack-frames > 256 bytes
On the bad side, the C library is currently only partially optimized for the 6502 and may be too big for some applications. Not all functionality is supported at the moment. Especially file I/O is missing (stdin/stdout to keyboard/screen is supported).
I have never used a BBC Micro and the port is based on a bit of information I got from the internet. So, there are probably some things I did completely wrong. Feel free to tell me how to do it right.
So far I could only test with an emulator and do not know what works on real hardware. The samples directory contains a few examples (dhrystone benchmark and calculator) compiled for the BBC Micro. I would be interested to hear if they work on real hardware.
vbcc optimizing C compiler for 6502 now supports bbc
Re: vbcc optimizing C compiler for 6502 now supports bbc
Amazing work! Writing a C compiler is no small task.
How does your compiler compare to cc65? Not so much in terms of BBC Micro support, more the core compiler. How does code size and performance compare for example? I use cc65 a fair bit, but I could be 'in the market for' something better
How does your compiler compare to cc65? Not so much in terms of BBC Micro support, more the core compiler. How does code size and performance compare for example? I use cc65 a fair bit, but I could be 'in the market for' something better

Re: vbcc optimizing C compiler for 6502 now supports bbc
Regarding features, my initial post lists probably the most important ones.Bobbi wrote: ↑Fri Oct 02, 2020 9:18 pmAmazing work! Writing a C compiler is no small task.
How does your compiler compare to cc65? Not so much in terms of BBC Micro support, more the core compiler. How does code size and performance compare for example? I use cc65 a fair bit, but I could be 'in the market for' something better![]()
Speed of the generated code can be several times faster than cc65, depending on opportunities for optimizations. The dhrystones benchmark which is included in the samples directory of my distribution gets ~234 dhrystones/s on a C64 compared to ~75 compiled with cc65 -Oisr. Other people have reported similar improvements, e.g. in those threads:
http://forums.nesdev.com/viewtopic.php? ... 26#p251672
http://forums.nesdev.com/viewtopic.php? ... 20#p254354
http://forums.nesdev.com/viewtopic.php? ... 20#p254433
https://www.lemon64.com/forum/viewtopic ... 3&start=17
Code size is more of a mixed bag. The library of vbcc is only partially optimized for 6502 yet, so programs using large library functions will have some overhead compared to cc65. The actual generated code can be smaller or larger. vbcc comes with a (still somewhat experimental) code compressor that can save quite some space. On the other hand, when optimizing for speed, the code can get bigger. The links above also have some code size comparisons, but I have not yet done a more thorough comparison yet.
Re: vbcc optimizing C compiler for 6502 now supports bbc
Do you have the instructions to integrate it into a local copy of compiler explorer properly?
I managed to get it to run in CE but only by using bin/vbcc6502 not the driver bin/vc. With bin/vc I got a "no config file" error
.
I managed to get it to run in CE but only by using bin/vbcc6502 not the driver bin/vc. With bin/vc I got a "no config file" error

-
- Posts: 1454
- Joined: Tue Apr 30, 2013 12:16 pm
- Contact:
Re: vbcc optimizing C compiler for 6502 now supports bbc
Good work. I'm looking forward to trying this! The optimizations look promising
Re: vbcc optimizing C compiler for 6502 now supports bbc
Yes I am looking forward to trying this out as well.
I have been secretly hoping for a better 6502 C compiler (secretly, because I was too lazy, and not smart enough, to do the hard work myself.)
I have been secretly hoping for a better 6502 C compiler (secretly, because I was too lazy, and not smart enough, to do the hard work myself.)
Re: vbcc optimizing C compiler for 6502 now supports bbc
I am not familiar with compiler explorer, but vc expects its config file in $VBCC/config. Maybe you did not set this environment variable?
Re: vbcc optimizing C compiler for 6502 now supports bbc
I have uploaded a new version: http://www.compilers.de/vbcc.html
Major changes since last update:
- new target: MEGA65 (native mode, some banking support)
- new target: Commander X16 (thanks András Péteri)
- new options -prefer-statics/-force-statics (allocate local variables in static memory rather than on the stack)
- new option -range-opt (first implementation of some range-based optimizations changing induction variables to smaller types)
- added support for o65 object file format
- added support for Oric target format
- better use of x register
- improved cross-module function-inlining
- IEEE math library works with 65c02
- several code generation improvements
- fixed several bugs
- slightly reworked examples
Major changes since last update:
- new target: MEGA65 (native mode, some banking support)
- new target: Commander X16 (thanks András Péteri)
- new options -prefer-statics/-force-statics (allocate local variables in static memory rather than on the stack)
- new option -range-opt (first implementation of some range-based optimizations changing induction variables to smaller types)
- added support for o65 object file format
- added support for Oric target format
- better use of x register
- improved cross-module function-inlining
- IEEE math library works with 65c02
- several code generation improvements
- fixed several bugs
- slightly reworked examples
Re: vbcc optimizing C compiler for 6502 now supports bbc
https://godbolt.org/z/JN4AOA compiler explorer, supports many other compilers (x86 etc), but I think that this is cc65, it's a bit hard to tell on the phone!
Same genius who wrote jsbeeb
Same genius who wrote jsbeeb
