Made a CPU in Logisim when I was 14 (2009), and wrote a naive assembler and compiler for it in Flash.
The CPU's design is inspired by Donn Stewart, http://cpuville.com.
The DrewCode compiler, written in Flash, can also compile to a Windows binary, which is actually an emulator for the CPU compiled for Windows. You can access it at http://compiler.drewgottlieb.net.
To use run the Brainf*ck interpreter, do the following:
- Install Logisim.
- Open assembler.swf. You'll need to have Flash Player installed on your system, or open it in Google Chrome.
- Paste in the contents of Assembly/BFOS.asm.
- Check the three checkboxes at the top ("INC/DEC", "PUSH/POP", "CALL/RET")
- Hit Assemble, it'll hang for several seconds.
- Copy the entirety of it output into your clipboard.
- Open cpu_2_bf.circ in Logisim.
- On the left side of Logisim, open the main circuit if it's not already opened.
- Right click on the RAM module labeled 2K RAM and click Edit Contents...
- Paste in the bytecode. Close the memory contents window.
- In the Logisim menu bar, select the following:
- Simulate → Tick Frequency → 4.1 KHz.
- Simulate → Ticks Enabled
- Select the finger tool (key: Meta-1)
- Click the Toggle Clock pushbutton within the circuit.
- Still using the finger tool, click on the rectangle of labeled ASCII Keyboard Input. You'll see a light blue ellipse circling the rectangle to indicate that it has your keyboard focus.
You'll see a welcome message appear on the screen labeled ASCII Terminal Output. If you don't see it, scroll right.
Once you see the bf>
prompt, type some Brainf*ck code and hit enter. If your code consumes input, you can type it at
this time.
In 2015 as an exercise in learning Swift, I created a virtual machine. View the full readme in the VM directory.