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
  • 10,777
  • 7
  • 58
  • 79
Tamás Szelei
  • 22,159
  • 16
  • 101
  • 174
  • 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 Путлер Капут 六四事 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
  • 613
  • 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
  • 189,938
  • 36
  • 271
  • 385
5

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

Yann Ramin
  • 32,436
  • 3
  • 56
  • 81
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
  • 86
  • 2
2

Possibly the AVR ATTiny45 or similar AVR chip.

Cory
  • 1,253
  • 12
  • 16
1

Maybe something from the Ti MSP430 series.

Aaron Altman
  • 1,610
  • 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
  • 71,941
  • 19
  • 102
  • 171