Building a simple computer interpreter in Python
We can take the concept of a simulator a step further and execute a program with multiple instructions using the concepts we just developed. Consecutive instructions are executed by reading them from program memory, one by one, and using a program counter to keep track of where we are in the program.
Please be aware of a possible source of confusion when we refer to a program. We are writing a program in the high-level language Python to simulate a computer. That simulated computer runs a program written in assembly language. Consequently, the term program can refer to two different entities. It should be clear from the context which one we are referring to.
Note that pseudocode is not a computer language, but a method of expressing a computer algorithm in almost plain English. So, a piece of pseudocode can represent either a high-level language such as Python or an assembly language.
In the following example, the source program...