Adding new instructions
So far, we have provided a modest set of instructions for TC1. In this section, we show how to add a new instruction to the TC1’s repertoire in order to see what’s involved in extending an instruction set. In fact, this is a remarkably straightforward task.
The first step is to choose a mnemonic and unique opcode and insert them into the table of code. We’ve arranged the instruction set to leave some unallocated code (e.g., code beginning with 11
). The second step is to write the code to interpret the new instruction.
First example – putting two memory locations in ascending order
Let’s create an instruction that takes the contents of two consecutive locations in memory and puts the largest number in the first location at the lower address (i.e., it orders them). This instruction takes a single parameter, a pointer register, and reads the numeric value pointed at by the register. We’ll assume that the register...