vbcc C compiler notes and status
Posted: Thu Aug 17, 2023 4:33 am
So today I wanted to give vbcc C compiler a try on the X16, because it say it supports the C99 standard that lets you do declarations and code at the same time. Old-school C (and cc65) requires all the declarations to be at the top of a function. I'm ok with that on new code, but trying to fire up some old code bases, the C99 updates would be nice.
So first step is "where to get vbcc" - and the place I went to was here:
http://www.compilers.de/vbcc.html
This seems to be last updated April 2022. It does have an X16 target (confusing since it also has a C16 target). And looks like there is a "reduced" or "tiny" X16R target as well.
Ok, so I gave it a try with a simple main - and it actually did produce a PRG that the r43 emulator would load. A few simple things worked (like a for-loop and printf on an integer). But fairly quickly, weird stuff started to happen in the produced PRG - like sprintf to do int to string conversion, and I'd end up with random garbage printed on the screen. I thought maybe the internal library was just converting to wrong display codes or something, but it was a different kind of random each time I ran it (so implies some kind of corrupted memory).
So, is this the "newest" vbcc distro to get? Does it work, but just avoid the standard library for now? I haven't yet seen examples for the inline assembly (and the .a's in the targets, I'm not seeing source for -- which is often good examples of how to do inline assembly, that's how I poked around in cc65).
For reference, here is how I'm doing the 6502 X16 build: (add the vbcc bin to path)
(or can use +x16r for that "reduced" or "tiny" stuff, I think)
The -I gets you much of the C standard library (no conio.h like cc65 has, but remember conio isn't really part of the C-standard library, iirc it was something Borland started providing with their compilers in the mid 1980s
Tracing "vc" a bit with this target, it seems to run vbcc6502.exe and then vasm6502_oldstyle.exe for you.
Anyone else further along with vbcc? Is this a good distro to be using? Again, it did make a valid formed PRG and did load, but it's a bit hit or miss on which parts of the standard library stuff works (not sure if r43 issues, or maybe still config issues on my part)
For now, going to stick with recommending cc65 for C and X16 r43.
So first step is "where to get vbcc" - and the place I went to was here:
http://www.compilers.de/vbcc.html
This seems to be last updated April 2022. It does have an X16 target (confusing since it also has a C16 target). And looks like there is a "reduced" or "tiny" X16R target as well.
Ok, so I gave it a try with a simple main - and it actually did produce a PRG that the r43 emulator would load. A few simple things worked (like a for-loop and printf on an integer). But fairly quickly, weird stuff started to happen in the produced PRG - like sprintf to do int to string conversion, and I'd end up with random garbage printed on the screen. I thought maybe the internal library was just converting to wrong display codes or something, but it was a different kind of random each time I ran it (so implies some kind of corrupted memory).
So, is this the "newest" vbcc distro to get? Does it work, but just avoid the standard library for now? I haven't yet seen examples for the inline assembly (and the .a's in the targets, I'm not seeing source for -- which is often good examples of how to do inline assembly, that's how I poked around in cc65).
For reference, here is how I'm doing the 6502 X16 build: (add the vbcc bin to path)
Code: Select all
set VBCC=f:\x16\vbcc_win_x64\vbcc
vc +x16 main.c -o test.prg -If:\x16\vbcc_win_x64\vbcc\targets\6502-x16
The -I gets you much of the C standard library (no conio.h like cc65 has, but remember conio isn't really part of the C-standard library, iirc it was something Borland started providing with their compilers in the mid 1980s
Tracing "vc" a bit with this target, it seems to run vbcc6502.exe and then vasm6502_oldstyle.exe for you.
Anyone else further along with vbcc? Is this a good distro to be using? Again, it did make a valid formed PRG and did load, but it's a bit hit or miss on which parts of the standard library stuff works (not sure if r43 issues, or maybe still config issues on my part)
For now, going to stick with recommending cc65 for C and X16 r43.