How to use cpu4 simulator

command line    cpu4 < input-S-format

The simulator takes object code input file in S-format.  It executes the instructions step by step and shows all the registers and flags.  A jump to subroutine 1001 (JSR 1001) will stop the simulator.  JSR 1000 prints the content of AC.   The variable "trace" controls the trace mode.  To turn off the trace assign "trace = 0" in the main() and recompile the simulator.  

In "run()" the limit is set to 1000 to prevent an infinite loop.  This number can be changed by recompiling the simulator.  

The simulator implements a Big Endian representation ( Hi byte first).  When pushing 16 bits value into the stack, Lo byte will be pushed first then Hi byte  (so that the number in the data segment and stack segment will be ordered in the same way).  

The output in trace mode displayed PC, instruction, AC, SP, and flags.  All numbers are in hexadecimal.  

Please report bugs to prabhas@chula.ac.th
