You know how I’ve written several times we’ll come back and fix/change stuff later?
We could torture ourselves by writing all our programs in hex, and if that’s your thing, this section is technically optional.
REPL stands for Read, Evaluate, and Print Loop. It is also referred to as the interactive interpreter for a language.
For example, if you open up Terminal or iTerm, we can look at Python’s REPL:
A More Advanced REPL
Our current REPL doesn’t do a ton, so let’s fix that. In this post, we’ll be adding some commands to look at the program bytecode and the registers and their contents, as well as actually execute code entered in as hexadecimal.
Hey, you’ve made it this far! Congrats! I wish I could say we’re near the end to give you some hope, but, well…sorry. =)
Today, we’re going to add some equality and comparison instructions! These will let us test us if the values in two registers are equal, not equal, greater than, or less than. These are easy to implement, so it shouldn’t take us too long.
Opcodes we’ll be creating are:
When we last left our intrepid tutorial followers, we had a simple VM that could add, subtract, multiply and divide. This is all fine and dandy, but we need more functionality than just that. In this segment, we’ll be adding some jump-related instructions.