This section describes the machine-level instructions that the Smalltium processor understands. The 4-digit binary number on the left is the opcode of the instruction. This is followed by the form of the assembly language instruction that represents this opcode, along with its arguments and an example. The next line shows what each bit in the machine language instruction word is used for in that instruction. An ``x'' in this representation means that it doesn't matter what that bit is. Other letters refer to bits that make up one of the arguments of that instruction. Following that is a description of what the instruction should do.
Ends the currently running program. This will cause the simulator to exit.
Loads an immediate value into register Rd (``Rd'' stands for destination register). Note that there are only 8 bits in the value argument to this instruction even though a register can contain 16 bits of information. This means the maximum immediate value is 255. If you want to load a value greater than this, you will need to put it in the data section of the program, then load it from memory (see the LOAD instruction below). The value can either be a number or a memory address (label).
Loads the contents of memory address Addr into register Rd. This instruction is how you read from memory. The address can only be an immediate value or address, not the contents of a register. To load from an address stored in a register, use the LOADi instruction (see below).
Stores the contents of register Rs to memory address Addr (``Rs'' stands for source register). This instruction is how you write to memory. The address can only be an immediate value or address, not the contents of a register. To store to an address stored in a register, use the STOREi instruction (see below).
. If the result of the
addition would be a number larger than 16 bits, ignore the overflow
and just put the low 16 bits into Rd.
. Because the
Smalltium cannot handle negative numbers, if
then the result should be 0.
. If the result of the
multiplication would be a number larger than 16 bits, ignore the overflow
and just put the low 16 bits into Rd.
. The remainder of the
division should be ignored. If
then you should
print out an error message and the program should halt.
Sets the flags based on a comparison between
and
(``Rt'' stands for test register).
There are four condition flags:
the first bit is always 1, the second bit is set to 1 if
, the third bit is set if
, and the last bit is set if
.
Check the flags to see if they match the condition c, and if so, jump to location Addr in the program and continue execution from there. Otherwise go to the next line. The condition will match if at least one of the 1 bits in the condition matches a 1 in the flags.
Here are the conditions:
Traps to the ``software'' layer for additional functionality such as I/O. See section 6 below for more information. ``Ra'' stands for argument register.
Calculates
, looks up that location in the
memory, and loads its contents into Rd (``Rb'' stands for base
register and ``Ri'' stands for index register). This provides
a convenient way to access arrays. Load the address of the beginning
of the array into Rb, and the index of the element you want into Ri.
This will add the two together to find the address of the particular
element you want. If you just have one register containing an
address you want to read from, you can use it as Rb, and use r0 as
Ri.
Calculates
, looks up that location in the
memory, and stores the contents of Rs into it.