Reading the posts around there it seems there are a few people who do actually use CC65 for the Oric on a regular basis.
Since I am dissatisfied with the output of the compiler currently used by the OSDK I am considering switching to CC65 but before I start experimenting with it I figured it would be simpler to ask you guys about it.
- From what I can read, it seems that CC65 is not fully capable of handling 8-bit only variables and will by default use 16 bits ints (it calls that the AX pair if I recall correctly what I read in the docs). Can you guys confirm? Is it possible to have "char" variables which are manipulated using a single register
- Have you had a chance to use CC65 with the library of the OSDK? If so, which adaptations were required?
- Are there ways to put variables in the zero page? The OSDK compiler apparently is aware of the zero page but it does not seem to offer any way to share it or control it explicitly.
Aside from these questions, if you guys were also willing to share your experience of CC65 in terms of ease-of-setup and ease-of-integration with the OSDK that would also be very welcome.
Thanks!
(leaching from the experience of better people ^^)
Questions to CC65 users
- NekoNoNiaow
- Flight Lieutenant
- Posts: 272
- Joined: Sun Jan 15, 2006 10:08 pm
- Location: Montreal, Canadia
Re: Questions to CC65 users
That's why I declare these variables in assembler modules, using .zero section marker, and in the C file I just use "extern" to access them.NekoNoNiaow wrote: ↑Tue Jan 15, 2019 2:33 am - Are there ways to put variables in the zero page? The OSDK compiler apparently is aware of the zero page but it does not seem to offer any way to share it or control it explicitly.
Re: Questions to CC65 users
Here are kind of answers from me :
First thing first - what are the sizes of the base types in CC65 and OSDK:
result:
Keep in mind in CC65 'float' and 'double' are valid type but there is NO support of float point math!
It's assembled with CC65 as:
And for the 3rd question DBug already answered - for CC65 works the same - use assembler module to define variable in ZP.
First thing first - what are the sizes of the base types in CC65 and OSDK:
Code: Select all
printf("char : %d\n", sizeof(char ));
printf("short : %d\n", sizeof(short ));
printf("int : %d\n", sizeof(int ));
printf("long : %d\n", sizeof(long ));
printf("float : %d\n", sizeof(float ));
printf("double : %d\n", sizeof(double));
This is easy to check:it seems that CC65 is not fully capable of handling 8-bit only variables and will by default use 16 bits ints...
...Is it possible to have "char" variables which are manipulated using a single register
Code: Select all
static char i,x,y;
void main(void)
{
x = 1;
y = 2;
i = x + y;
}
Code: Select all
;
; x = 1;
;
.dbg line, "test.c", 36
lda #$01
sta _x
;
; y = 2;
;
.dbg line, "test.c", 37
lda #$02
sta _y
;
; i = x + y;
;
.dbg line, "test.c", 38
lda _x
clc
adc _y
sta _i
Re: Questions to CC65 users
And for this one:
- how the result is returned: OSDK uses A(msb):X(lsb), CC65 uses X(msb):A(lsb). And because I'm always forgetting which one is the correct for the particular compiler, I use a macro at end of assembler function which returns 'int':
- how the parameters are passed to functions: in OSDK they are always 16-bit, in CC65 ... hmmm, it depends ... the best is to read CC65 docs. In short, my approach is to avoid functions with parameters - I'm using simply global variables .
Yes, but only 'void func(void)' works as is . There are differences in:- Have you had a chance to use CC65 with the library of the OSDK? If so, which adaptations were required?
- how the result is returned: OSDK uses A(msb):X(lsb), CC65 uses X(msb):A(lsb). And because I'm always forgetting which one is the correct for the particular compiler, I use a macro at end of assembler function which returns 'int':
Code: Select all
#ifdef __OSDK__
#define return(x) .byt $a2, <x, $a9, >x, $60
#else
#define return(x) .byt $a9, <x, $a2, >x, $60
#endif
Re: Questions to CC65 users
That's also the approach I'm using.
Even when the best and tightest tweaks of the universes, the C compiler will always generate shitty code compared to the assembler. It's not a problem of smart engineering, it's a problem of data model not matching the CPU 6502 strengths and weaknesses.
It's definitely possible to improve the parameter passing, better tailor the size of variables, etc... but ultimately there are not enough registers, not enough zero page, not enough stack space, so the only sane solution Fabrice found was to use this crazy second stack that allows us to run almost standard C programs that do recursion and all kind of other crazy things without too much struggle.
It's really the usual balance between performance and features, which is why I recommend CC65 for people who want all the comfort of a toolchain that is designed to be generic portable and using the usual linking system, while the OSDK is for people who want to hack around like there was no tomorrow, look at the generated assemble code, etc...
I would be ok in using CC65 instead of LCC, but I refuse to use the linker and assembler that comes with it, saying that I don't like the syntax is like saying that Linus Torvalds has strong opinion against certain things
Re: Questions to CC65 users
+1
Using C is great for prototyping, creating the main structure of your code, small utilities, but far from the needs of serious programming that pushes the limits of the machine. For that, you need asm. Plain and simple.
Mixing C and asm with the current OSDK toolchain is very simple. When Fabrice and I developed Pinforic (not using OSDK, it did not exist yet, but using LCC and frasm) I started with pure C code. I ran out of space, so I went for the global-variables-instead-of-parameters thing and I could put everything into the Oric's RAM leaving 2K (IIRC) for pages of game data read from disk. It was sloooooow, so Fabrice came into rescue and started rewriting functions in asm. Man that was incredible! He rewrote most of the interpreter and now it is smal and fast!
The only better way to go is forgetting about C and use only asm. XA is excellent for that purpose.
Re: Questions to CC65 users
cc65 usesNekoNoNiaow wrote: ↑Tue Jan 15, 2019 2:33 am - Are there ways to put variables in the zero page? The OSDK compiler apparently is aware of the zero page but it does not seem to offer any way to share it or control it explicitly.
Code: Select all
#pragma zpsym (<name>)
- NekoNoNiaow
- Flight Lieutenant
- Posts: 272
- Joined: Sun Jan 15, 2006 10:08 pm
- Location: Montreal, Canadia
Re: Questions to CC65 users
Thanks!