Lab 4 - Instructions

Related Reading

4.1 The Machine Language

Hardware machines have a built-in set of instructions that they can decode and execute. We now study how to extend our implementation with representations of the machine instructions.

The instruction set of the machine is in Table 4.1 (see p. 204 of the book).

Binary opcodeDecimal opcodeOperation
(X is a machine address)
0000
0
LOAD X
0001
1
STORE X
0010
2
CLEAR X
0011
3
ADD X
0100
4
INCREMENT X
0101
5
SUBTRACT X
0110
6
DECREMENT X
0111
7
COMPARE X
1000
8
JUMP X
1001
9
JUMPGT X
1010
10
JUMPEQ X
1011
11
JUMPLT X
1100
12
JUMPNEQ X
1101
13
IN X
1110
14
OUT X
1111
15
HALT
Table 4.1 Instruction Set

To extend our implementation of the machine, the first step is to write Java definitions for the instructions. Since we will need to distinguish the instructions from each other, we will have a separate class for each instruction. Recall that the Instruction class is a subclass of the Word class, just as Data and Address are subclasses of the Word class. Your job is to design and implement 16 different classes, one for each machine instruction. Each of these 16 different classes representing machine instructions should be a subclass of the Instruction class.

E.g. A possible hierarchy might look like:

		Word
		  |
	-------------------  
	|	  |        |
    Data    Address   Instruction
			   |
			-----------------------------------
			|         |          |    
		    LoadIns   StoreIns  ClearIns    . . . 


Feel free to add additional levels to the hierarchy for your convenience.

4.2 Exercise

Your job is to design and implement sixteen different machine instruction classes according to the following specifications: While you are free to design the instruction classes however you wish (as long as they satisfy the above specifications), you should carefully consider topics discussed in lecture and try to develop the most elegant solution possible.

Turn in the code for the machine instruction classes during class on Monday, May 3rd.


Visited times since March 23, 1999 (or the last crash).

Last modified: 04/21/99 09:38:25

yreimer@cs.uoregon.edu