How to use cpu3 simulator

command line    cpu3 < 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 instructions that are not implemented are : INA, OUT,  and interrupt.

The output in trace mode displayed PC, instruction, AC, X, SP, and flags.  All numbers are in hexadecimal.  PC is the PC after the current instruction is executed (i.e. the next PC).   For example :  running this program will display 

.s
stop 1001
.a 0
.c
	lda #1
	rol
	lda #1
	stc
	. . .
	jsr  stop
.e

pc    2 lda A  1 X    0 SP  3E7 INCZ 0000
pc    3 rol A  2 X    0 SP  3E7 INCZ 0000
pc    5 lda A  1 X    0 SP  3E7 INCZ 0000
pc    6 stc A  1 X    0 SP  3E7 INCZ 0010

Please report bugs to prabhas@chula.ac.th
