19

In terms of instruction set and simplicity of emulation. I would like to implement a virtual CPU and figured why not emulate an existing one, so to be able to compile C code to it.

Lii
  • 11,553
  • 8
  • 64
  • 88
Tamás Szelei
  • 23,169
  • 18
  • 105
  • 180
  • Another route is to search for backends to single instruction set architectures: https://stackoverflow.com/questions/3711443/minimal-instruction-set-to-solve-any-problem-with-a-computer-program People seem to have done a clang backend for subleq: https://stackoverflow.com/questions/3711443/minimal-instruction-set-to-solve-any-problem-with-a-computer-program/38523869#38523869 – Ciro Santilli OurBigBook.com Sep 08 '17 at 07:08

7 Answers7

23

Moxie is a great target because it was designed specifically to be an ideal target for GCC. I am the author and would be happy to answer any questions. green at moxielogic dot com

Anthony Green
  • 643
  • 1
  • 4
  • 9
  • Is there reference documentation about the architecture and instructions set? – Tamás Szelei Feb 02 '11 at 14:48
  • What there is exists at http://moxielogic.org/wiki ... although it will take me a bit to undo damage from the wiki vandals. Check back soon. – Anthony Green Feb 02 '11 at 17:11
  • Can Moxie architecture be used in a closed source commercial project (think inclusion of it's emulator in a video game)? On your site I didn't find a license that clearly specifies that. – ezolotko Jan 04 '16 at 22:31
  • 1
    Hi @ezolotko. Thanks for asking. The answer is, in general, yes. I'll try to update the docs/website soon, but please contact me directly at green AT moxielogic.com. Thanks again. – Anthony Green Jan 06 '16 at 03:10
6

GCC supports Moxie (originally ggx), a little architecture invented by Anthony Green for experimentation.

You, too, can follow the steps he took to invent your own small simple CPU and port GCC to it.

ephemient
  • 198,619
  • 38
  • 280
  • 391
5

ZPU (an FPGA targeted 32bit processor) is very small.

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82
2

This probably isn't an uncommon question; I'd hope that most CPU/machine simulation toolkits would include a simple example implementation, but some don't.

I haven't worked with it, but Knuth's MMIX architecture (wikipedia) looks interesting. Like Moxie, it was created to "illustrate machine-level aspects of programming" and is simpler than real machines. It's supported by GCC and there appear to be multiple existing simulators that could be used as a reference in your efforts.

Mike Mondy
  • 76
  • 2
2

Possibly the AVR ATTiny45 or similar AVR chip.

Cory
  • 1,291
  • 12
  • 16
1

Maybe something from the Ti MSP430 series.

Aaron Altman
  • 1,705
  • 1
  • 14
  • 22
1

MIPS I (one of the targets of GCC) is a surprisingly easy-to-emulate 32-bit platform. Here is an short and simple emulator which can load and run a statically linked Linux MIPS I executable: https://github.com/pts/pts-mips-emulator

pts
  • 80,836
  • 20
  • 110
  • 183