Every instruction is represented as its own class, all of which extend SamInstruction or one of its subclasses. An instruction that extends SamInstruction is one that does not have any operands. Instructions that need an operand extend one of the subclasses of SamInstruction - SamIntInstruction, SamFloatInstruction, SamCharInstruction, etc... These subclasses provide the op variable in the appropriate type which is set to the operand provided to the instruction. All included instructions are prefixed by SAM_, which is removed automatically when the instruction is actually used.
Instructions do not check the types of any input values they use. In the default SamProcessor implementation, floats, for example, are stored as integers using standard Java float->integer conversion routines. An integer operation that is given a float as input will produce unexpected results. Some instructions, such as ADD, SUB, DUP, SWAP, ISNIL, NOT and EQUALS are defined on multiple data types. Refer to the ISA manual for details.
Apart from the op variable, which is provided to operand classes, instructions also have access to the cpu (the processor), mem (the memory), video (the video interface), sys (the system object), and prog (the program that the instruction is a part of).
Creating a new Instruction
To create a new instruction: