Simplest C compiler to retarget

Programming, for all ages and all languages.
Post Reply
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Simplest C compiler to retarget

Post by iammisc »

I have written a virtual machine and I would like to be able to run C on this machine just for fun. The thing is, I don't have a C compiler. Now, I know that there are some compilers meant for this stuff(lcc for example), but the thing is that my virtual machine doesn't have a fixed number of registers but rather it has an arbitrary per-subroutine register number and it also has a quite high-level bytecode. What would be the simplest compiler to use for this? Should I even use a standard compiler or should I attempt to write my own(I have some experience with compiler design)? Have you successfully retargeted a compiler?

AFAICT, all the retargetable C compilers make certain assumptions about their backends, which generally means that backends only produce the most low-level code. However, since my bytecode is really high-level, I do not know if any compiler would be able to handle it.

What do you think?
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: Simplest C compiler to retarget

Post by DeletedAccount »

If you are happy with a subset of C , then give small C a try :) . But it is easier to write a pascal compiler by hand than a full blown c complier ( implementing sets can be a bit difficult :) ) ,ie try a modified version of pascal . The pascal grammar is available from the Writh's book , u can use a simpler variation of the grammar to write a pretty simple pascal compiler


Regards
Evil Sandeep
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Simplest C compiler to retarget

Post by AndrewAPrice »

I've spent several weeks on this issue for my console since it has a different architecture to most. I'd recommend VBCC since it even comes with a template generic backend you can start with.
My OS is Perception.
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: Simplest C compiler to retarget

Post by DeletedAccount »

Take a look at PLY as well , compilers can be easily prototyped with ply . Thou shall rely heavily on the visitor pattern

Regards
Saint Lucifer
Post Reply