Close

Straight to C?

A project log for One-instruction TTL Computer

A breadboard-able computer which uses only a single instruction - MOVE

justin-davisJustin Davis 06/04/2017 at 17:112 Comments

Since I've been writing in "assembly", I remember how much I don't like writing in assembly. It's just so limiting. This processor doesn't even have microcode, so it takes a lot of instructions to do just about anything. It would be very handy to implement macros. I'm thinking I may skip the assembler and go straight to C functions. I could write a simple function which takes two bytes, and outputs the machine code to a file. And then use that function in larger functions. So if I want to move a constant to ALUA which is normally two instructions, I could write a macro to do it in one. That's sounding a lot more appealing. There's a lot to think about for where to put the instructions in memory and doing jumps to labels. I guess that's about the same as writing an assembler, but I get to stay in C. Is there a term for this type of assembler? not quite assembly language and not quite C.

Discussions

agp.cooper wrote 06/06/2017 at 06:12 point

Hi Justin,

I have thought about a C compiler for my Weird CPU (another "MOVE" only instruction CPU) but while using an existing C compiler and re-configuring CPU instruction set is possible, it did not seem easy.

However I have come across an online/offline C compiler for SUBLEQ (http://mazonka.com/subleq/hsq.html) which gets you to code that is almost compatible to a MOVE CPU syntax. The Mazonka C compiler is big but could be modified for a MOVE syntax. 

Although expensive you could convert the SUBLEQ syntax to a MOVE syntax quite easily. I figure (for my CPU) the three byte SUBLEQ syntax would require ten bytes for a MOVE syntax (five instructions for my CPU if I swapped the ADD instruction for a SUB instruction). 

In the end I thought in my case I would be better off building a SUBLEQ CPU rather than continue with the MOVE CPU. Particularly as Mazonka has written a C compiler for SUBLEQ already.

The upside for a SUBLEQ CPU is that there is nothing stopping you from using MOVE type hardware access for increased performance. The best of both worlds: a C Compiler and ALU hardware.

Hope this helps, regards AlanX.

  Are you sure? yes | no

Justin Davis wrote 06/06/2017 at 13:56 point

Thanks, I will check it out and see if I can adapt any of it for my project.

  Are you sure? yes | no