bbc-c
bbc-c copied to clipboard
[Question] How to compile and use
Hi! Thanks for your project!
How is your compiler built? Is it a patch of GCC or CC65 or a totally independent compiler?
Is it C89 compliant + // comments?
I would like to use it in my toolchain.
How do you use it? Does it come with a linker?
Fabrizio
+1 to this. Seems like it's written in python3 and needs numpy to run, but a requirements.txt
with dependencies and a README on how to use would be ace. I'd love to put this on Compiler Explorer. (See mattgodbolt/compiler-explorer#82)
A README would be great! tfw you get @mattgodbolt themselves asking to add it to compiler explorer damn
I've put together a proper readme now. @Fabrizio-Caruso to answer your question; this project attempts to be GCC compatible, however, I cannot make any guarantees that it is even consistent with itself.
Fabulous. Are there any docs on the ASM output? I just naïvely tried to integrate into Compiler Explorer and the output from -S
doesn't look much like 6502 to me: is there some smart assembler I need to run too to get 6502 out? (I can support the IR version too, maybe?)
it looks like it is as good as you are gonna get, still looks like decent 6502 assembly to me soooo shrug @mattgodbolt might have to wait for @TheEnbyperor to get back to you on this one. to me it looks like normal assembly for the BBC Micro but with extra instructions for calling functions that get linked to it
@NamedKitten let me show what I got when I compiled a simple piece of code with python3 main.py -S /tmp/moo.c
:
.export square
// Function: square
square:
push %r12
mov %r14, %r12
// Mult
mov DWORD 8[%r12], %r0
mul DWORD 8[%r12], %r0
// Return
__bbcc_00000000:
mov %r12, %r14
pop %r12
ret
Now I've read the documentation and I see that there's a VM that interprets this: the output is not 6502. Or am I missing something? There's no step that can turn this into straight 6502?
Thanks!
No, the output isn't 6502. The only translation layer that exists currently from my own IS to 6502 is the VM. The compiler did output 6502 at one time but doing C compliant 16bit and 32bit integers on an 8bit processor resulted in a lot of repeated boilerplate, so I made the VM. I could probably quite easily make something to convert the VM's IS to native 6502, but that doesn't exist currently.
Thanks for clarifying @TheEnbyperor :grinning: