Custom C Compiler for homemade instruction set?
I need an instruction set, but I am not crazy enough to try and make it run the x86 instruction set or anything like that, so I am making my own. It is a fairly basic set, only 60 instructions, with a quarter of them being data movement. I tried compiling some basic computation programs, like a 16-bit add and an 8-bit multiply program. It is a pain trying to compile it so I was wondering if there is a way to plug my instruction set into a compiler, such as gnu's gcc. I don't even need it to create a machine code file, I just need the assembly.
Is something like this possible??? and how hard would it be to implement???






























Visit Our Store »
Go Pro Today »




Thanks for any help
Will your machine have a call/return/parameter stack and subroutines, or will it all be inline code? I strongly suspect that GCC, or any other existing compiler, will be designed around stack machines. If you don't have a stack you can write code to implement one -- we sorta had to do that for serious 6502 programming, since its hardware stacks were very small and really intended for local/microcode use.
I'm still designing it and I've made like a million changes to the designs :D, but so far I've been tossing the idea of possible stack. It won't be pretty and it would probably be overly complex yet ridiculously simple, but hopefully it will work. If I can't get a working stack, then it will obviously be inline, so I would just use a bunch of jumps to all of the addresses.
You are probably right that GCC is based around stack machines. Most everything uses a stack...hmmm...
Steve