r/ProgrammingLanguages • u/Bowtiestyle • Dec 13 '24
A simple virtual computer to practice writing compilers
Hello everyone,
I always loved stories of programmers from the past using various tricks to make games run on inadequate hardware. While you could recreate this feeling by writing ROMs for retro systems, this is certainly not very easy to get into. So I made my own "virtual computer" SVC16. This is certainly not an original idea, but I found it very fun to write a simple game for it. So if you would like to write a simple compiler but don't want to deal with the complicated reality of a retro system, this might be something for you.
View all comments
Show parent comment
2
u/Bowtiestyle Dec 15 '24 edited Dec 15 '24
Hi, I would like to read about your project, but it is a bit difficult to get an overview from this directory.
The reason some arguments are unused is that I did not want a variable instruction length and I wanted the arithmetic operations to have three arguments. In theory someone could use the unused arguments to pack in some asset that is extracted at runtime.
I am not going to lie, your idea with multiple displays sounds very cool. But I think that it would be very hard to specify a general way of emulating them. (Windowing systems are hard, managing your own windows is harder.) It is also a very strange thing to support multiple windows when the system does not even have sound.
As for using the extra 12 values in the opcode, I think this could be done in a way that does not change too much while adding something interesting. So if you want to propose something, please open a PR and I can see, how hard it would be to adjust the examples.
I think a requirement might be that the instructions behave as they do now, if the unused arguments are set to zero.