Tutorials - SIC/XE machine

Tutorials - SIC/XE machine

Virtual machine

Design and start to implement a class Machine which will represent a basis for your simulator. With this class (and other supporting classes) you should be able to represent the SIC/XE computer (registers, memory and devices).


Think about (before you implement) how to support all (programatically visible) registers of the SIC/XE computer: : A, X, L, B, S, T, F. Some helpful questions

  • How many bits do you need to represent one register?
  • How you will represent a register?
  • Do you need getters and setters for the registers, such as getA() in setA(int val)?
  • How will you represent the F register? Hint: check the IEEE single/double types and compare them to SIC/XE float - check bit representations.

Add support for the PC (program counter) register.

  • Do this similarly as for the programatically visible registers.

Add support for the SW (status word) register.

  • Notice that, we need only a small part of the register. In particular we need only CC (condition code), which is used with instructions such as COMP, JLT, JEQ, ... Hence, instead of full SW support, we focus only on support for CC.
  • Hints: use values -1, 0, 1 for representing the results of comparison instruction COMP., (i.e., <, ==, >). You can stored this result directly in some class attribute CC.
  • Anyway, you should also have a getter and setter for the SW register. In particular, getSW() should return 0, 0x40, 0x80 respectively to a value in CC (i.e., -1, 0, 1). You will need this for displaying proper value of SW register.

Besides getters and setters you will also need to access register by their index.

  • We need indexed getter/setter, e.g., getReg(int regno) in setReg(int regno, int val).
  • Notice the indices of registers are 0, ..., 5 for registers A, X, L, B, S, T, respectively.
  • Define also the constants for the register indices.


Add support for the main memory.

  • How big is the address space of SIC/XE computer. Define the constant MAX_ADDRESS.
  • How will you store particular memory cells?

Design getter and setter for accessing the memory by bytes, e.g.,

  • int getByte(int addr)
  • void setByte(int addr, int val)
  • What happens when address is not in the memory range?
  • Why the signature of the above two functions uses int (but not byte) type?

Do the same also for accessing the memory by words.

  • How bit is a word in the SIC/XE architecture?
  • Hint: to implement getWord(int addr) you can 3 times call getByte(int addr).

(*) Do the same for accessing the memory by floats - if you want add support for floats.

  • How big is float in SIC/XE? Compare it to IEEE/Java double.
  • Hint: useful methods Double.doubleToLongBits() and Double.longBitsToDouble(...).


Think about devices you want to support.

a) We need a class Device with methods

  • boolean test() - for executing the TD instruction
  • byte read()RD instruction
  • void write(byte value)WD instruction

In the SIC/XE machine add support for 256 devices. You will again need getters and setters:

  • Device getDevice(int num)
  • void setDevice(int num, Device device) 

b) Implement classes InputDevice and OutputDevice for supporting readable (reading from the InputStream) and writable (writing to OutputStream) devices, respectively. Both should have a constructor where the read/write stream is specified.  

Update the initialisation of the machine so that devices numbers 0, 1, and 2 are connected to standard input/output/error streams.

c) Implement class FileDevice which represent read/write device connected to a file (the name of the file is specified in its constructor). Hint: RandomAccessFile.

Update also the initialisation of the machine for all the devices numbered 3 or more.

Operation codes - opcodes

Design class Opcode, which includes constants for all the opcodes of SIC/XE computer. For example

public static final int LDA = 0x00;
public static final int LDX = 0x04;

Last modified: Friday, 9 November 2018, 12:24 PM