vbcc optimizing C compiler for 6502 now supports bbc
-
- Posts: 215
- Joined: Tue Jul 03, 2007 10:40 am
- Location: italy
- Contact:
Re: vbcc optimizing C compiler for 6502 now supports bbc
Thanks for the effort vbc. I am eager to test your latest improvements.
Re: vbcc optimizing C compiler for 6502 now supports bbc
Hi everyone,
I am trying to use vbcc to display some redefined character on some screen mode but I am not able to set the screen to any graphics mode.
If I do set it in BASIC before starting the vbcc binary, I do sort of get the result but it looks like to binary is loaded in screen memory (I see gibberish on the screen and on top of it I see the redefined character).
In order to do this things I am using the ROM routines by just "printing" control sequences on screen as described in the code below.
What am I doing wrong?
Fabrizio
I am trying to use vbcc to display some redefined character on some screen mode but I am not able to set the screen to any graphics mode.
If I do set it in BASIC before starting the vbcc binary, I do sort of get the result but it looks like to binary is loaded in screen memory (I see gibberish on the screen and on top of it I see the redefined character).
In order to do this things I am using the ROM routines by just "printing" control sequences on screen as described in the code below.
What am I doing wrong?
Fabrizio
Code: Select all
#include <stdint.h>
#include <stdio.h>
static uint8_t stripes[] = {255,0,255,0,255,0,255,0};
void redefine(uint8_t ch, uint8_t *data)
{
uint8_t i;
putchar(23);
putchar(ch);
for(i=0;i<8;++i)
{
putchar(data[i]);
}
putchar('\n');
}
void _XL_INIT_GRAPHICS(void)
{
// Set mode 3
putchar(22);
putchar(3);
// Delete graphics screen data
putchar(16);
// Redefine character 240
redefine(240,stripes);
// Redefine character 241
redefine(241,stripes);
// Display some text
putchar('O');
putchar('K');
printf("hello world\n");
// Display character 240
putchar(240);
// Display character 241
putchar(241);
// Display "hello world"
printf("\nhello world\n");
while(1){};
}
Re: vbcc optimizing C compiler for 6502 now supports bbc
I'm possibly being a bit dense, but I'm struggling to get it to work.
Windows install, I've edited the path and set the VBCC path, and I've trued various combinations of command line options, and editing the vc.cfg file.
The closest I've got to success is with a heavy edit of the vc.cfg where I fully expand all the paths. That gets me through the compile of a single source file, and a temporary object file created. But it fails at the link stage, with unresolved externals, and I can't get it to accept libraries into the link.
I'm fully prepared to accept that I've possibly made a mistake somewhere in the setup that has broken something, but I'm struggling to see what.
Trying to compile the simplest possible file:
I get:
Reference to undefined symbol __main ... in startup.o
Anyone know the obvious cause - or any suggestions as what daft mistake I've made?
Thanks
Windows install, I've edited the path and set the VBCC path, and I've trued various combinations of command line options, and editing the vc.cfg file.
The closest I've got to success is with a heavy edit of the vc.cfg where I fully expand all the paths. That gets me through the compile of a single source file, and a temporary object file created. But it fails at the link stage, with unresolved externals, and I can't get it to accept libraries into the link.
I'm fully prepared to accept that I've possibly made a mistake somewhere in the setup that has broken something, but I'm struggling to see what.
Trying to compile the simplest possible file:
Code: Select all
int main(void) {
return 0;
}
Code: Select all
D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>vc nothing.c -o test
startup.o: In "l3":
Error 21: startup.o (text+0x2b): Reference to undefined symbol ___main.
vlink -m -b bbc -Cvbcc -TD:\Downloads\vbcc6502_r3p3\vbcc6502\vbcc6502_win\vbcc/targets/6502-bbc/vlink.cmd -LD:/Downloads/vbcc6502_r3p3/vbcc6502/vbcc6502_win/vbcc/targets/6502-bbc/lib D:/Downloads/vbcc6502_r3p3/vbcc6502/vbcc6502_win/vbcc/targets/6502-bbc/lib/startup.o "C:\Users\rgodi\AppData\Local\Temp\vbcc068c.o" -o test failed
Anyone know the obvious cause - or any suggestions as what daft mistake I've made?
Thanks
Re: vbcc optimizing C compiler for 6502 now supports bbc
It is more portable for those actual character variables/parameters/pointers(rather than raw bytes) to be declared as a (plain) char, as their signedness is compiler dependant and they are characters rather than general integer byte variables otherwise a compiler with signed chars won't /shouldn't compile the above with its uint8_t characters.Fabrizio wrote: ↑Thu Jun 16, 2022 10:10 pm Hi everyone,
I am trying to use vbcc to display some redefined character on some screen mode but I am not able to set the screen to any graphics mode.
If I do set it in BASIC before starting the vbcc binary, I do sort of get the result but it looks like to binary is loaded in screen memory (I see gibberish on the screen and on top of it I see the redefined character).
In order to do this things I am using the ROM routines by just "printing" control sequences on screen as described in the code below.
What am I doing wrong?
Fabrizio
Code: Select all
#include <stdint.h> #include <stdio.h> static uint8_t stripes[] = {255,0,255,0,255,0,255,0}; void redefine(uint8_t ch, uint8_t *data) { uint8_t i; putchar(23); putchar(ch); for(i=0;i<8;++i) { putchar(data[i]); } putchar('\n'); } void _XL_INIT_GRAPHICS(void) { // Set mode 3 putchar(22); putchar(3); // Delete graphics screen data putchar(16); // Redefine character 240 redefine(240,stripes); // Redefine character 241 redefine(241,stripes); // Display some text putchar('O'); putchar('K'); printf("hello world\n"); // Display character 240 putchar(240); // Display character 241 putchar(241); // Display "hello world" printf("\nhello world\n"); while(1){}; }
I wonder if C11+n should create an actual plain_char_t type for characters and deprecate usage of the char keyword for them?
Re: vbcc optimizing C compiler for 6502 now supports bbc
I'd suggest to start with the default installation. After setting the VBCC environment variable and PATH, please post the output of the following commands (assuming your nothing.c example is in the current directory):
Code: Select all
echo %VBCC%
vc +bbc -v nothing.c
Seems like the linker command in your config file is missing -lvc to link with the standard library.Trying to compile the simplest possible file:I get:Code: Select all
int main(void) { return 0; }
Reference to undefined symbol __main ... in startup.oCode: Select all
D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>vc nothing.c -o test startup.o: In "l3": Error 21: startup.o (text+0x2b): Reference to undefined symbol ___main. vlink -m -b bbc -Cvbcc -TD:\Downloads\vbcc6502_r3p3\vbcc6502\vbcc6502_win\vbcc/targets/6502-bbc/vlink.cmd -LD:/Downloads/vbcc6502_r3p3/vbcc6502/vbcc6502_win/vbcc/targets/6502-bbc/lib D:/Downloads/vbcc6502_r3p3/vbcc6502/vbcc6502_win/vbcc/targets/6502-bbc/lib/startup.o "C:\Users\rgodi\AppData\Local\Temp\vbcc068c.o" -o test failed
Re: vbcc optimizing C compiler for 6502 now supports bbc
It is indeed. If I add that, nothing.c compiles and links.
I started with the default, and gradually worked away from it, getting steps to work bit by bit. But I ground to a halt with the linker error.vbc wrote: ↑Mon May 29, 2023 6:48 pm I'd suggest to start with the default installation. After setting the VBCC environment variable and PATH, please post the output of the following commands (assuming your nothing.c example is in the current directory):Code: Select all
echo %VBCC% vc +bbc -v nothing.c
Here is what I get from the echo and vc with verbose on:
Code: Select all
D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>vc +bbc -v nothing.c
vc frontend for vbcc (c) in 1995-2020 by Volker Barthelmann
vbcc6502 -I"%VBCC%"/targets/6502-bbc/include -quiet "nothing.c" -o= "C:\Users\rgodi\AppData\Local\Temp\vbcc068c.asm" -unsigned-char -mainargs -mask-opt -O=1
vbcc V0.9i pre (c) in 1995-2022 by Volker Barthelmann
vbcc 6502 code-generator V0.5 (c) in 2022 by Volker Barthelmann
error 6: No input file
aborting...
1 error found!
vbcc6502 -I"%VBCC%"/targets/6502-bbc/include -quiet "nothing.c" -o= "C:\Users\rgodi\AppData\Local\Temp\vbcc068c.asm" -unsigned-char -mainargs -mask-opt -O=1 failed
D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>
Thank you very much!
ETA:
And once I managed to get the inf file association sorted, the programs load and run, including using the floating point libraries and printf. So, It seems to be working nicely.
And now to work!
(Well, actually, to bed, since it's late.... but, soon, to work!)
Re: vbcc optimizing C compiler for 6502 now supports bbc
It is good to hear that at least you found a workaround to get it working for now.
The output from echo %VBCC% was missing. Could you add that?Here is what I get from the echo and vc with verbose on:
Code: Select all
D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>vc +bbc -v nothing.c vc frontend for vbcc (c) in 1995-2020 by Volker Barthelmann vbcc6502 -I"%VBCC%"/targets/6502-bbc/include -quiet "nothing.c" -o= "C:\Users\rgodi\AppData\Local\Temp\vbcc068c.asm" -unsigned-char -mainargs -mask-opt -O=1 vbcc V0.9i pre (c) in 1995-2022 by Volker Barthelmann vbcc 6502 code-generator V0.5 (c) in 2022 by Volker Barthelmann error 6: No input file aborting... 1 error found! vbcc6502 -I"%VBCC%"/targets/6502-bbc/include -quiet "nothing.c" -o= "C:\Users\rgodi\AppData\Local\Temp\vbcc068c.asm" -unsigned-char -mainargs -mask-opt -O=1 failed D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>
The command lines look ok to me. If you copy (or type by hand) the vbcc6502-command above and execute it directly, do you get the same error?
Are you using a normal Windows with a standard command window or are you using a special shell or something like that?
Re: vbcc optimizing C compiler for 6502 now supports bbc
the echo %VBCC% gives me this:
Code: Select all
D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>echo %VBCC%
D:\Downloads\vbcc6502_r3p3\vbcc6502\vbcc6502_win\vbcc\
Standard Windows command line - no special shell, tools, or anything wrapping it.
If I run the command line as given, I get the same error - error 6: No input file
If I use my config file with the full paths it works. If I try to use the platform specific config files, it fails to find the files. It just doesn't seem to be expanding the variables the one one might expect.
I would be nice to get it working as intended - I dislike having to rely on hacks and hard coded exceptions.
(And that may be easier than figuring out how to make make system calls to talk to econet and then draw graphics....!)
Re: vbcc optimizing C compiler for 6502 now supports bbc
This may be a daft question... (long time since I wrote any code for what's a kind of essentially embedded system) - but vbcc doesn't seem to allow setting of pointers to absolute values, only to null.
So... how do I address specific memory locations? Say, for memory mapped I/O, or screen memory?
Sorry if these are basic questions or if I'm missing something obvious.
So... how do I address specific memory locations? Say, for memory mapped I/O, or screen memory?
Sorry if these are basic questions or if I'm missing something obvious.
Re: vbcc optimizing C compiler for 6502 now supports bbc
Could you try removing the trailing backslash from the VBCC environment variable? I think it interferes with the quotes in the generated command line. I probably should add some code to check for that.Ragster wrote: ↑Tue May 30, 2023 11:53 pmCode: Select all
D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>echo %VBCC% D:\Downloads\vbcc6502_r3p3\vbcc6502\vbcc6502_win\vbcc\
Re: vbcc optimizing C compiler for 6502 now supports bbc
Just cast the value to the pointer type, e.g.:Ragster wrote: ↑Fri Jun 02, 2023 11:09 pm This may be a daft question... (long time since I wrote any code for what's a kind of essentially embedded system) - but vbcc doesn't seem to allow setting of pointers to absolute values, only to null.
So... how do I address specific memory locations? Say, for memory mapped I/O, or screen memory?
Code: Select all
int *p=(int *)0x1234;
Re: vbcc optimizing C compiler for 6502 now supports bbc
With the backslash removed, it seems as though it works as intended - using a specified config (e.g. +bbcr) it finds the input files and compiles.vbc wrote: ↑Sat Jun 03, 2023 3:35 pmCould you try removing the trailing backslash from the VBCC environment variable? I think it interferes with the quotes in the generated command line. I probably should add some code to check for that.Ragster wrote: ↑Tue May 30, 2023 11:53 pmCode: Select all
D:\Downloads\vbcc6502_r3p3\vbcc6502\samples>echo %VBCC% D:\Downloads\vbcc6502_r3p3\vbcc6502\vbcc6502_win\vbcc\
Thanks - mystery solved.
And the casting for the pointer set seems to work too - at least it compiles... Now to see if I can make it do what I want, and start building the libraries I need...
Cheers!