Tutorials - SIC/XE emulation

Tutorials - SIC/XE emulation

Handling errors 

What a processor does when there is an error such as addressing a location in the memory out of range? What will your simulator do?

Define several methods for handling such troubles. You can write an error message on the standard output for errors. For example:

  • invalidOpcode(int opcode)
    • Executor tried to execute the opcode which is not defined.
  • invalidAddressing()
    • Invalid addressing bits.

Think about the errors hard :). However, later you can add other error handling methods.

Byte fetch

Write a method

  • int fetch()

which reads a byte from the PC address and returns it. It also increments the PC.

Executor

Write a method

  • void execute()

which decodes instruction and any possible operands. It uses the fetch method.

We also need the following methods (see also the slides):

  • boolean execF1(int opcode)
  • boolean execF2(int opcode, int operand)
  • boolean execSICF3F4(int opcode, int ni, int operand)

Processor clock

a) Add support for processor clock and automatic execution of instructions. Use Java's Timer class.

The machine needs several new methods:

  • start() - starts or continues automatic execution
  • stop() - stops (pauses) automatic execution
  • isRunning() - tells if automatic execution is enabled.

You can set a your Timer for example to 1 millisecond. How many kHz is this?

b) Java's Timers are sometimes troublesome, they do not support very find-grained resolution.

To speed up the execution, instead of pushing the timer interval down to its limits, its is often better to do much work on each timer tick. For example you can execute 100 instructions instead of one. Your emulation will then run much more smoothly.

c) Add support for setting the computer speed:

  • getSpeed()
  • setSpeed(int kHz)
Last modified: Friday, 9 November 2018, 12:49 PM