CPU simulator project
Hello everyone. This is my first post here. I am doing a course in programming on Codecademy and as a part of this course one of the tasks was to make a blog post about my project. As the title says, it is a simple CPU simulator. I created it with help from ChatGPT and it follows a simple logic.
For my registers I used a dictionary for fast retrieval, the instructions list is tuple based and for executing the instructions a lamba function is used when identifying the right opcode.
Here is a sample screenshot how the program looks like:
In this part of the program we see the initialization of the CPU as well as the most important part of the program with the opcode. This is modified version after refactoring, the initial version used a list of a disctionary. The code is slightly less readable due to the use of lambda funtions, but I believe it runs faster than regular functions.
Get Celestin Krajina-Roso’s stories in your inbox
Join Medium for free to get updates from this writer.
There is a link to the repository here.
In conclusion, this project was interesting because it shed more light on how a CPU works, which I didnt really know before I started learning this part of the course on Codecademy. Now looking back, I think its fairly straightforward, (somewhat) simple but effective.
Until next time,
Celestin



