The Simpletron Machine Language

Only available on StudyMode
  • Topic: Branch, Control flow, Conditional
  • Pages : 3 (902 words )
  • Download(s) : 168
  • Published : December 25, 2012
Open Document
Text Preview
The Simpletron Machine Language (SML)
Each instruction written in the Simpletron Machine Language (SML) occupies one word of the Simpletron's memory (and hence instructions are signed five-digit decimal numbers). The 2 leftmost digits of each SML instruction are the operation code(opcode), which specifies the operation to be performed. The 3 rightmost digits of an SML instruction are the operand, which is the memory location containing the word to which the operation applies. The complete set of SML instructions is described in the table that follows.

We illustrate how the Simpletron executes SML programs (using the instructions from the table above) with the use of two example SML programs. Consider the following SML program which reads two numbers and computes and prints their sum.

Execution always begins at memory location 000. The word at memory location 000 (+10007) is read and interpreted as an instruction. The leftmost two digits of the word (10) represent the instruction and the rightmost three digits (007) represent the instruction's operand. The first instruction is a READ operation. This reads a single word from the input file (explained in section 3) and stores it in the memory location defined by the operand, in this case memory location 007. READ and WRITEinstructions always operate on memory locations. This completes the execution of the first instruction. Processing continues by executing the next instruction found at memory location 001. The next instruction (+10008) reads a second word from the input file and stores it in memory location 008. The next instruction (+20007) is a LOAD operation with operand 007. It takes the word found at memory location 007 (the operand) and places it into the accumulator (recall that the accumulator is one of the six registers described in section 1). All LOAD and STOREoperations move data in and out of the accumulator. The next instruction (+30008) is an ADD instruction with operand 008. All SML...
tracking img