Skip to main content

Posts

Showing posts from September, 2021

Emulator Deep Dive - The Instruction Set: Part 4

This is the fourth part in this series, and will cover flow control instructions. You can find the first post here , the second here , and the third here . Prerequisites None of the flow control operations use the data stack, and only two make use of the return address stack, so knowing about stacks is less important in this post than in the others. Knowledge of other assembly language variants would definitely be an asset, as these follow the same patterns found in other processors. Last Time The last post covered arithmetic and logic unit (ALU) instructions, which modify the condition code (CC) register. Many of the flow control instructions make use of the CC flags to determine whether or not to move execution flow elsewhere. Jumps Jump ( jmp , jsr , rts ) instructions change the program counter (PC) to an absolute address in memory. They are all unconditional, that is, the change in the PC happens regardless of the system's state. jmp changes the PC to an address specified as ...

Emulator Deep Dive - The Instruction Set Part 3

This is the third post in this series and will cover arithmetic and logic unit (ALU) instructions. The operations are pretty straightforward, and there are few caveats, if any. You can find a table of these instructions at the end of the post. You can find the first post here , the second here . Prerequisites There are a couple of prerequisites to fully understanding this series of posts. It will assume you know what a stack is and that you have some knowledge of assembly language. But the content could still be interesting even without that knowledge. I'll leave it to you to decide. Last Time In the last post I covered stack and memory manipulation instructions. Those instructions allowed for manipulation of the values on the stack; shuffling items around, adding items, and removing them. They can be combined with ALU instructions to produce a number of effects. ALU instructions These instructions apply mathematical operators to values from the stack. ALU operations operate exclus...

Emulator Deep Dive - The Instruction Set: Part 2

This is the second post in this series, and will cover stack manipulation instructions. You can find a table of all the stack instructions at the end of this post. You can find the first post here . Prerequisites There are a couple of prerequisites to fully understanding this post. It will assume you know what a stack is (but I've included a refresher) and that you have some knowledge of assembly language. But the content could still be interesting even without that knowledge. I'll leave it to you to decide. Notation The table at the end of this post uses a stack effect notation typically used by Forth . These effect notations are enclosed in parentheses, and consist of a before state and an after state, separated by two dashes. For instance, the swap instruction exchanges the top two items on the stack. This would be noted as (a b -- b a) , showing that before the instruction is executed, b is at the top of the stack, and a is one below the top of the stack. After t...