Installation and Test of the Z80 simulator:
The executable program could be installed under /usr/local/bin, but on most systems this would require root permissions, which you might not have. So the example shows how to install it in the bin directory of the users home directory.cd ~/z80pack-x.y/z80sim make mv z80sim ~/bin make cleanYou now have a Z80 simulation with all possible debugging support compiled in. If you don't need all this debugging support, but want the fastest possible CPU speed instead, remove sim.h, link sim.h.fast to sim.h and recompile. You also could create your own sim.h with features enabled/disabled to serve your needs.
z80pack includes some Z80 source code examples, which can be used to do first tests. If you do not have a Z80 cross assembler installed on your system already, you need to install the included assembler first. The following examples make use of the Z80 cross assembler included in z80pack.
Change to directory ~/z80pack-x.y/z80src and assemble the example programs:
z80asm float Z80 - Assembler Release 1.3, Copyright (C) 1987-2006 by Udo Munk Pass 1 Read float.asm Pass 2 Read float.asm 0 error(s) z80asm z80main Z80 - Assembler Release 1.3, Copyright (C) 1987-2006 by Udo Munk Pass 1 Read z80main.asm Include z80dis.asm Resume z80main.asm Include z80ops.asm Resume z80main.asm Pass 2 Read z80main.asm Include z80dis.asm Resume z80main.asm Include z80ops.asm Resume z80main.asm 0 error(s)Now load float.bin in z80sim and execute it:
z80sim ####### ##### ### ##### ### # # # # # # # # # # ## ## # # # # # # # # # # # # ##### # # ##### ##### # # # # # # # # # # # # # # # # # # # # # # # ####### ##### ### ##### ### # # Release 1.8, Copyright (C) 1987-2006 by Udo Munk >>> r float.bin Loader statistics for file float.bin: START : 0000 END : 0684 LOADED: 0685 >>> g 40400000 00700000 7F800000 35BFFFFF 00400000 7F7FFFFF 7F800000 406DB6DB 15400001 HALT Op-Code reached at 00c9 PC A SZHPNC I IFF BC DE HL A'F' B'C' D'E' H'L' IX IY SP 00ca 0d 000001 00 00 1540 0001 0000 0000 0000 0000 0000 0280 0000 012e >>>This example program includes Z80 floating point routines and a main program, that does several non-trivial computations. If you get the result above on your system, chances are good that z80sim runs ok.
Now try out the program z80main.bin, this is a Z80 disassembler program which disassembles the complete sorted Z80 instruction set from file z80ops.asm. The disassembler displays 15 lines of output and then runs a HALT instruction, which stops emulation of the program. Type more g commands to continue with the disassembly.
C compiler optimization:
The z80pack sources are distributed with very conservative compiler optimization options in the makefiles. This options are supposed to work with any C compiler on any UNIX system. Please note that it is well worth to read your compilers manual about optimization. As an example changing CFLAGS in Makefile on x86 UNIX platforms using the GNU C compiler to:CFLAGS = -O3 -mcpu=i686 -minline-all-stringops -c -Wallresults in a ~25% faster virtual system on many modern x86 platforms!