tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] new backend


From: Paul Moore
Subject: Re: [Tinycc-devel] new backend
Date: Thu, 18 Apr 2024 00:10:04 +0000

I want to create a lite c compiler for the HACK computer described in “the elements of computing systems” aka ‘nand to tetris’ – here, Home | nand2tetris. A fun read.

 

I have implemented the system on an fpga and want to cross compile c code to it.

 

It’s a 16bit machine – I reckon that’s the biggest challenge. It also has only one hardware register, no shifts or rotates and no stack in hardware. I can obviously emulate extra registers in fixed ram locations and manage a stack myself.

The book implements a lite java like language for the machine so its not an insurmountable problem

 

I am hesitating going forward with tcc on this. Its heritage as 32 bit 386 is very clear, it knows how stacks are laid out, it wants only PE or elf ……

 

If I ever want to try to host a compiler on the system (way off…) then the all in one aspect of tcc is actually a downside, the tcc executable is big enough to compile, assemble and link. One of the good things about separate steps for those is that each phase is smaller

 

I have looked at a couple of other compilers as starting points

  • Cc65, this is a 6502 compiler, so 16 bit addressing. I know this compiler pretty well, having written a debugger for its generated code. Its interesting to note that cc65 is HUGE compared to tcc and yet is not as feature rich. On the plus side its one of the cleanest code bases I have ever seen. No random globals with names like ‘ind’ and ‘loc’ 😊
  • Pcc – this seems like a good candidate as it supports the pdp11 which is a 16 bit system and that compiler runs on it, so its lean and mean. I just started looking at it and am currently descending into the nightmare of bison, m4, autoconf… All tools I had hoped to never have to work with again (I am a windows guy)
  • I also toyed with the idea of making llvm backend. Its doable for 16 bit , there is a 6502 compiler that uses clang to cross compile to commodore 64 etc.

 

 

From: tinycc-devel-bounces+paulmoore100=hotmail.com@nongnu.org <tinycc-devel-bounces+paulmoore100=hotmail.com@nongnu.org> On Behalf Of Detlef Riekenberg via Tinycc-devel
Sent: Wednesday, April 17, 2024 4:51 PM
To: tinycc-devel@nongnu.org
Cc: Detlef Riekenberg <wine.dev@web.de>
Subject: Re: [Tinycc-devel] new backend

 


Hi Paul

Can you please tell me more about the new backend,
which you are working on?
Either here or with private mail.
Thanks.

> Well somewhere along the way I fixed it
> when I started making gjmp and gjmp_append return sane values.
 
Great

> Are there any docs out there that describe how to write a backend.

I'm not aware of any additional doc.
You can also look at the commit history of recent added backends.

> The doc here Tiny C Compiler Reference Documentation (bellard.org
> seems way way out of date

It's build from the source tree: tcc-doc.texi

Can you please add Everything, what you learned during your
backend development,?
(I suggest to upstream it after the 0.9.28 release from @grischka)

> Any guidance, gotchas, tips are welcome
 
I'm also interested in everything related to this topic.

--
Regards ... Detlef


reply via email to

[Prev in Thread] Current Thread [Next in Thread]