bbc-c icon indicating copy to clipboard operation
bbc-c copied to clipboard

[Question] How to compile and use

Open Fabrizio-Caruso opened this issue 6 years ago • 8 comments

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

Fabrizio-Caruso avatar Sep 22 '18 08:09 Fabrizio-Caruso

+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)

mattgodbolt avatar Mar 31 '19 16:03 mattgodbolt

A README would be great! tfw you get @mattgodbolt themselves asking to add it to compiler explorer damn

chaoticryptidz avatar Jun 05 '19 19:06 chaoticryptidz

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.

TheEnbyperor avatar Jun 17 '19 13:06 TheEnbyperor

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?)

mattgodbolt avatar Jun 20 '19 12:06 mattgodbolt

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

chaoticryptidz avatar Jun 20 '19 15:06 chaoticryptidz

@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!

mattgodbolt avatar Jun 21 '19 02:06 mattgodbolt

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.

TheEnbyperor avatar Jun 21 '19 08:06 TheEnbyperor

Thanks for clarifying @TheEnbyperor :grinning:

mattgodbolt avatar Jun 25 '19 01:06 mattgodbolt