Monday, February 27, 2023

Toy CPU Simulator

This is a DOS game. Download toy.exe to play it on FreeDOS or DOSBox or any other DOS system. Compile the source code using OpenWatcom.

I teach university courses part-time, and one course that I teach is MIS 100, where students learn how technology works. For our section on "programming," I usually talk about programming in very abstract terms, because these are not Computer Science students. But this year, I wanted to try something new.

I hoped to start the "programming" discussion by walking my students through a history of programming, so they could see the next step and how that worked. I tried to find a simple hobby "educational" computer, similar to the Altair 8800, where you input a series of program instructions in "machine language" (binary opcodes) using switches and LEDs. I wanted the instructions to be simple enough that my students could write a few simple programs, like A+B=C, and use that as a starting point to write the same program in Assembly, and in C, and ... you get the idea.

But I couldn't find a suitable "Altair-like" SBC for less than $100. There are "Altair" software emulators out there, but they faithfully reproduce the Altair 8800, and that was too much overhead for my needs.

So I decided to write my own hobby "educational" computer. I call it the Toy CPU.

I wrote a rough prototype on DOS using character mode, but you couldn't enter a program on the "front panel." Instead, you had to hard-code a program into memory, and recompile to run that. It was very primitive, but enough to know that it worked.

Later, I completely rewrote the Toy CPU using Linux ncurses. This was still a prototype, but this time you could enter a program on the "front panel" by "flipping bits." It looked okay in ncurses, but I really wanted a graphical program.

Open Jam 2022 came up at the right time! I decided to completely rewrite the Toy from scratch, using FreeDOS and other open source tools. I don't use graphical assets per se; instead, the Toy draws the interface elements using basic graphical functions from OpenWatcom (open source). If you're curious: I used FED (open source) as my editor. I ran FreeDOS inside VirtualBox (open source) running on top of Fedora Linux (open source). Everything in the pipeline was open source.


The theme for Open Jam 2022 is "Light in the Darkness," which is a perfect fit for the Toy CPU, because of all the blinkenlights!

More information, including opcodes and sample programs you can try out are on my GitHub project.



from Hacker News https://ift.tt/LqVXbKW

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.