How to use z0 simulator

Get the package "sim-z0-1.zip".  Use the z0 simulator executable in the directory sim-z0\test\  "z0.exe".
The input file is the z0 machine code.  Here is the example:  ex2.txt
The input file format is:  
(opcode operand)*    ; 1 or more repeat
0                    ; end of code
address len          ; data section
num*                 ; repeat len times
0                    ; end of data

You can put initialised date in the data section (such as the search linked list example). 

To run the simulator, use the command line console (called "cmd" in Windows).  Then type "z0 file.txt"  where file.txt is your machine code file (called object file).  The simulator has its own "command".  Inside the simulator type "h" (help) for list of commands.  The basic one is "t" (trace, single step), "z 1" turn on trace display, and "g" (go).  You can see all registers with "r" and memory with "d address len" (dump).  Exit from the simulator by "q" (quit). Here is a sample session with  add 1 to 10 program (ex2.txt).  We do the first session by running the program in one go, using "g" while turn on the trace display ("z 1").

C:path>z0 ex2.txt
load program, last address 16
>h
g - go
t - single step
b ads - set breakpoint
c - clear breakpoint
s [rn,mn,pc] v - set
d ads n - dump
r - show register
z [1,0] - display
o - show output
q - quit
h - help
>z 1
> g
. . .
PC  12 inc r1            AC:55 r0:0 r1:11 r2:55 r3:10 r4:0 r5:0 r6:0 r7:0
PC  13 jmp 6             AC:55 r0:0 r1:11 r2:55 r3:10 r4:0 r5:0 r6:0 r7:0
PC   6 mov r1            AC:11 r0:0 r1:11 r2:55 r3:10 r4:0 r5:0 r6:0 r7:0
PC   7 le r3             AC:11 r0:0 r1:11 r2:55 r3:10 r4:0 r5:0 r6:0 r7:0
PC   8 jf 14             AC:11 r0:0 r1:11 r2:55 r3:10 r4:0 r5:0 r6:0 r7:0
PC  14 stop              AC:11 r0:0 r1:11 r2:55 r3:10 r4:0 r5:0 r6:0 r7:0
>q
C:path>

Next session, we ran it in single step.

C:path>z0 ex2.txt
load program, last address 16
>t
C:\Users\Prabhas\Dropbox\mywin\z0\sim-z0\lcc>z0 ex2.txt
load program, last address 16
>t
PC   0 mvi 10            AC:10 r0:0 r1:0 r2:0 r3:0 r4:0 r5:0 r6:0 r7:0
>t
PC   1 put r3            AC:10 r0:0 r1:0 r2:0 r3:10 r4:0 r5:0 r6:0 r7:0
>t
PC   2 mvi 1             AC:1 r0:0 r1:0 r2:0 r3:10 r4:0 r5:0 r6:0 r7:0
>

Enjoy!

last update 2 Sept 2014