Digital Research
This commit is contained in:
2020-11-06 18:50:37 +01:00
parent 621ed8ccaf
commit 31738079c4
8481 changed files with 1888323 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
9 March 2011 - SJK
------------------
z80em86 v1.0.2
Changes:
* Update links in documentation.
3 September 2009 - SJK
----------------------
z80em86 v1.0.1
Changes:
* Links in README file updated to new CP/M 3 system support site.
27 February 2009 - SJK
----------------------
z80em86 v1.0.0
Initial release:
z80em86 is a Z80 CPU emulator with hardware emulation coded entirely in
Intel 86 assembly language and designed to run under MSDOS. The emulator
will also run under Windows 98/Me/2000 (XP/Vista not tried) as a 16 bit
application and under DosEmu on Linux systems.

View File

@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@@ -0,0 +1,62 @@
z80em86 Software distributions
==============================
The latest source and binary distributions are available from:
http://www.cpm.z80.de/source.html
http://www.gaby.de/z80/z80emu.htm
The "n.n.n" is the version number:
z80em86-n.n.n.tar.gz : Source files
z80em86-n.n.n-dos.zip : Binary in ZIP format for DOS (and Windows)
Installation
============
For DOS/Windows systems the binary ZIP may be used. On Linux systems a DOS
binary can be installed under DosEmu after the sources have been built or
the binary distribution may also be used.
DOS ZIP file
------------
1. Unzip the DOS z80em86-n.n.n-dos.zip binary distribution to a
location you wish to use. If you have a previous installation then you
can just unzip over the top of the other.
2. Follow the instructions under 'ALL SYSTEMS'.
SOURCE BUILD/INSTALL
--------------------
During the Make process the 'ALINK' linker sources will be automatically
downloaded, modified and built, the file is less than 50K in size. The
download process normally only needs to run once as the file will be cached
in the build area.
$ tar -xzf z80em86-n.n.n.tar.gz (n.n.n is the version number)
$ cd z80em86-n.n.n/src
$ make
If the current user has access to DosEmu (~/.dosemu/drive_c/...) then the
emulator can be installed in that location and run under DosEmu.
$ make install
Follow the instructions under 'ALL SYSTEMS' before proceeding.
The emulator can be run from the Makefile or by starting DosEmu and changing
directory to the installed location.
To run from the Makefile (after install):
$ make run run booting Z80HDD.DSK under dosemu
$ make runa run forcing booting A: under dosemu
$ make runb run forcing booting B: under dosemu
ALL SYSTEMS
-----------
A Z80 operating system may be placed in the 'z80em86' directory as a HDD
image disk file or a system from a floppy drive may be booted. A CP/M 3
system suitable for running under the emulator is available. See the
doc/README file for further information.
A z80hdd.exe utility in the 'z80em86' directory can be used to create a 4MB
formatted HDD disk image.

View File

@@ -0,0 +1,644 @@
********************************************************************************
z80em86
A Z80 emulator coded in Intel 86 assembly language
Copyright (C) 1992-2009 Stewart Kay
For contact details please see the 'Contact' section at the end of this file.
********************************************************************************
Distribution License
====================
See license.txt in this distribution.
Overview
========
z80em86 is a Z80 CPU emulator with hardware emulation coded entirely in
Intel 86 assembly language and designed to run under MSDOS. The emulator
will also run under Windows 98/Me/2000/XP (Vista/W7 not tried) as a 16 bit
application and under DosEmu on Linux systems.
The coding for this Z80 emulator started sometime back in 1992 and was
mainly complete by 1993 with some further minor changes made in 1995. Other
changes have been made recently to allow the program to work under Windows
2000 as a 16 bit application. The software was never released and is now
being released for the first time under the GPL.
The emulator does not try to be fancy but does support a basic DOS Window
interface system and supports hardware emulation allowing Z80 operating
systems to be coded for it.
The idea to write the emulator came to surface when I purchased an IBM
compatible i386 machine and wanted to learn 8086 Assembly language so I
decided that coding up a Z80 emulator to run under DOS would be an
interesting and educational exercise. The goal was to produce a Z80
emulator to run as fast as possible and to emulate the Z80 documented
instruction set.
The emulator as it stands also supports some generic hardware emulation
functions that makes it possible to boot and run a Z80 operating system.
The emulator can boot from a floppy disk or a HDD disk image.
The entire memory allocated to z80em86 by DOS on start-up is freed and the
memory re-allocated. Two banks of 64K each are allocated for use as system
banks allowing banked operating systems to be implemented. 16K is allocated
to a DOS window system and the remainder is allocated in 16K blocks usable
by a Z80 operating system. Typically these extra blocks can be used to
implement a RAM disk.
A fully implemented CP/M 3 banked and non banked system with support
utilities is also available to be used with the emulator. This is not
supplied with z80em86 but will be made available elsewhere. See 'Z80
Operating systems' section near the end of this document.
A slightly modified CP/M program 'zexdoc.com' has been used for testing.
See 'Tesing z80em86' section below.
The software is well organised and broken up into module groups as defined
in the Z80 CPU documentation.
The following is a list of ideas for possible future development:
1. Convert to 32 bit assembly language.
2. Add cycle counting for each opcode.
3. Add optional memory and IO handler functions.
4. Add interrupt support.
5. Add undocumented Z80 instructions and flags.
6. Provide a build option to compile without hardware emulation support so
that it just emulates Z80 code and provide a 'C' wrapper.
7. Add multi processor support.
You can get the emulator package(s) from here:
http://www.cpm.z80.de/source.html
http://www.gaby.de/z80/z80emu.htm
RUNNING Z80EMU86
================
Starting
--------
The emulator may be started with some options on the command line. The user
may optionally specify if a floppy disk 'A' or 'B' is to be booted from
instead of a HDD disk image.
Boot from floppy drive A:
>z80em86 -a
Boot from floppy drive B:
>z80em86 -b
If no drive options are specified the emulator will check for a HDD raw disk
image file (z80hdd.dsk) or if that does not exist prompt the user to insert
a floppy disk into drive 'A' to boot from.
The emulator will attempt to load the first sector from side #0, track #0
from the HDD image or floppy disk into memory at address 80 hex in the Z80
memory map. The PC register will be set to address 80 hex and the SP
register to address FFFF hex upon execution.
The Z80 emulator now executes the Z80 code at address 80 hex which most
likely contains some sort of boot strap loader for loading an operating
system into memory.
In addition to the optional floppy drive parameter a second parameter can be
passed that a Z80 system can make use of. One of the support programs for
the CP/M 3 system that runs under the Z80 emulator makes use of this
parameter allowing a submit file or a CP/M 3 command to be passed.
Interrupting emulation
----------------------
As the emulator is running, execution can be interrupted by pressing the
CTRL+ALT+I keys to bring up a DOS Window of options. These allow the
emulator to be Reset (R), Exit to DOS (E) or Continue (C). This provides a
convenient method to pause the emulator then resuming by selecting Continue.
DOS critical error handler
--------------------------
Emulation employs a DOS critical error handler that will display a DOS
window message if any critical error occurs during emulation.
Z80 CPU emulation
=================
Emulation of all Zilog documented instructions is supported except for I/O,
interrupt and related instructions. A DOS Window message will report any
non emulated instruction.
Handling of some Z80 instructions
---------------------------------
IM 0 : Interrupt mode #0, the emulation of this code stops the emulator
and prompts the user to reset the Z80 or exit to DOS.
IM 1 : Interrupt mode #1, same action as IM 0
IM 2 : Interrupt mode #2, same action as IM 0
DI, EI : Disable/Enable Interrupts, these instructions only affect the Z80
IFF flags. These have no affect on the host system's interrupts.
HALT : Halt processing, the halt instruction halts the emulator and
alerts the user that the HALT instruction was executed and then
prompts the user to reboot the CP/M system.
IN, OUT : Input/Output port, all input/output (and block) instructions are
ignored as these are hardware dependent. The emulator will stop
and alert the user that an IN/OUT instruction was executed and
then prompt the user to reboot the CP/M system.
RETI : Execution is halted.
RETN : Execution is halted.
LD A,I : Emulated but does nothing.
LD I,A : Emulated but does nothing.
LD A,R : Emulated but does nothing.
LD R,A : Emulated but does nothing.
Z80 and 8086 register/memory relationships
------------------------------------------
Z80 Register 8086 Register/(Memory)
A AL
B CH
C CL
D DH
E DL
H BH
L BL
I (Z80I)
R (Z80R)
AF AL + SAHF
BC CX
DE DX
HL BX
PC BP
SP (Z80SP)
IX (Z80IX)
IY (Z80IY)
AF' (Z80AF)
BC' (Z80BC)
DE' (Z80DE)
HL' (Z80HL)
Variable Bits Description
FlagN 8 Emulates the Z80 N flag
Z80SP 16 Z80 stack pointer storage
Z80IX 16 Z80 X index register storage
Z80IY 16 Z80 Y index register storage
Z80BC 16 Z80 2nd BC register storage
Z80DE 16 Z80 2nd DE register storage
Z80HL 16 Z80 2nd HL register storage
Segments
reg ES (extra segment addresses the Z80 memory map segment)
reg DS (data segment addresses tables and data)
reg CS (code segment is the emulator code segment)
reg SS (stack segment is the stack pointer segment)
Hardware emulation
==================
The emulator supports emulation of hardware and other host system calls by
making use of one of the Z80's OUT instructions:
OUT (Fn),A
Where 'Fn' is the required function and allows up to 256 functions at the
base level. As the emulator was originally designed not to emulate I/O
opcodes this provided a convenient method to access emulated hardware.
The functions are contained in the 'T7' table found in the 'table.asm'
assembly file.
Functions 00-1FH - Keyboard
---------------------------
Fn(H) Table name Description
00 kbd1in Initialise kbd1
01 kbd1st kbd1 status
Return: A(AL)=Keyboard status (not ready=0)
02 kbd1ip kbd1 input
Return: A(AL)=Keyboard character
10 kbd2in Initialise kbd2 (STDIN)
11 kbd2st kbd2 status (STDIN)
Return: A(AL)=STDIN status (not ready=0)
12 kbd2in kbd2 input (STDIN)
Return: A(AL)=STDIN character
Functions 20-3FH - CRT
----------------------
The CRT emulates a Televideo 920/ADM-3A Video Terminal on crt1 and provides
STDOUT on crt2 using the DOS video service.
Fn(H) Table name Description
20 crt1in CRT #1 Initialise
21 crt1st CRT #1 ready status
Return: A(AL)=output status
22 crt1op CRT #1 output character
Pass: C(CL)=output character
30 crt2in CRT #2 Initialise (STDOUT)
31 crt2st CRT #2 ready status (STDOUT)
Return: A(AL)=output status
32 crt2on CRT #1 output character (STDOUT)
Pass: C(CL)=output character
Functions 40-4FH - LPT
----------------------
Fn(H) Table name Description
40 lptini Initialise LPT port
Pass: DE(DX)=LPT port (0-3)
41 lptsta LPT ready status
Pass: DE(DX)=LPT port (0-3)
Return: A(AL)=output status (not ready=0)
42 lptout LPT output character
Pass: DE(DX)=LPT port (0-3)
C(CL)=output character
Functions 50-5FH - COMMUNICATIONS
---------------------------------
Fn(H) Table name Description
50 comini Initialise com port
Pass: DE(DX)=Coms port (0-3)
A(AL)=baud/parity/data bits/stop bits
51 comist Input status
Pass: DE(DX)=Coms port (0-3)
Return: input status in reg A(AL)
52 cominp Input byte
Pass: DE(DX)=Coms port (0-3)
Return: input character in reg A(AL)
53 comost Output status
Pass: DE(DX)=Coms port (0-3)
Return: output status in reg A(AL)
54 comout Output byte
Pass: DE(DX)=Coms port (0-3), C(CL)=output character
Functions 60-6FH - TIME/DATE
----------------------------
Fn(H) Table name Description
60 gettme Get time
Pass: reg HL(BX) = Z80 address to return results
Return: mem[HL(BX)+0] = hours in BCD
mem[HL(BX)+1] = minutes in BCD
mem[HL(BX)+2] = seconds in BCD
61 settme Set time
Pass: reg HL(BX) = Z80 address of parameters
mem[HL(BX)+0] = hours in BCD
mem[HL(BX)+1] = minutes in BCD
mem[HL(BX)+2] = seconds in BCD
62 getdte Get date
Pass: reg HL(BX) = Z80 address to return result
Return: mem[HL(BX)+0] = days since 31st December 1977
63 setdte Set date
Pass: reg HL(BX) = Z80 address of parameter
Return: mem[HL(BX)+0] = days since 31st December 1977
Functions 80-8FH - DISK
-----------------------
Fn(H) Table name Description
80 rdflop Read floppy disk
Pass: A(AL)=sector size code (0=128, 1=256, 2=512, 3=1024)
B(CH)=track number
C(CL)=sector number
D(DH)=side select
E(DL)=drive code (0=drive A, 1=drive B)
HL(BX)=buffer address
Return: A(AL)=0 if no errors, 1 if error
81 wrflop Write floppy disk
Values same as 'rdflop'
82 rdhard Read hard disk image
Pass: B(CH)=track number
C(CL)=sector number
E(DL)=drive code (2=drive C, 3=drive D etc)
HL(BX)=buffer address
Return: A(AL)=0 if no errors, 1 if error
83 wrhard Write hard disk image
Values same as 'rdhard'
84 GtBoot Get boot drive
Return: A(AL)=boot drive
85 GtHard Get hard disk drive
Return: A(AL)=HDD drive or FFh if none
86 FlHard Flush HDD file buffer
Functions 90-9FH - MEMORY BLOCKS
--------------------------------
Fn(H) Table name Description
90 blkcnt Get count of blocks available (1 block=16384 bytes)
Return: A(AL)=number of blocks
91 blkget Get 128 bytes from block (1 record=128 bytes) from
the current DMA bank. (see bnkdma function)
Pass: C(CL)=block number
D(DH)=starting record number
E(DL)=number of records
HL(BX)=Z80 destination address
92 blkput Put 128 bytes in block (1 record=128 bytes) for
the current DMA bank. (see bnkdma function)
Pass: C(CL)=block number
D(DH)=starting record number
E(DL)=number of records
HL(BX)=Z80 source address
93 blkfil Fill 128 bytes in block (1 record=128 bytes) for
the current DMA bank. (see bnkdma function)
Pass: A(AL)=fill value
C(CL)=block number
D(DH)=starting record number
E(DL)=number of records
Functions A0-BFH - INTERRUPT SERVICES
-------------------------------------
Fn(H) Table name Description
A0 GtZseg Return Z80 map segment address
Pass: HL(BX)=Z80 address to place result
A1 intfnc Call a ROM BIOS/DOS Interrupt service
Pass: BC(CX)=0AA55h
DE(DX)=055AAh
HL(BX)=base address of register table
A(AL)=Interrupt
B0 GetByt Get byte from memory
Pass: DE(DX)=segment
HL(BX)=offset
Return: A(AL)=byte
B1 SetByt Set byte in memory
Pass: DE(DX)=segment
HL(BX)=offset
A(AL)=byte
Functions F0-F7H - BANKING
--------------------------
Fn(H) Table name Description
F0 bnkuse Set bank size to use
Pass: BC(CX)=sets banking, size of bank #0, #1
F1 bnksel Select bank
Pass: A(AL)=bank 0 or 1
F2 bnkmve Move memory in current bank or bank to bank
Pass: HL(BX)=destination address
DE(DX)=source address
BC(CX)=amount to be moved
F3 bnkdta Set destination and source banks
Pass: B(CH)=destination bank
C(CL)=source bank
F4 bnkdma Set DMA bank #0 or #1
Pass: A(AL)=DMA bank 0 or 1
Functions F8-FFH - CONTROL
--------------------------
Fn(H) Table name Description
F8 prmsta Get parameter passed status
Return: A(AL)=FFh if parameter passed
F9 prmget Get the parameters address
Pass: HL(BX)=Z80 address to place result
Return: Z80[HL+0]=parameter buffer data segment
Z80[HL+2]=parameter buffer offset
FA vidsta Get the video on/off status
Return: A(AL)=FFh if video is off
FB vidset Set video on/off
Pass: A(AL)=FFh turn video off
FC usrbyt Get/Set a user byte (0-31)
Pass: C(CL)=0 to get, else set
A(AL)=byte to set (if set)
HL(BX)=byte offset (0-31)
Return: A(AL)=get byte (if get)
FD failed Set boot strap failure
FE rstz80 Reset the Z80 emulator
FF extemu Exit the Z80 emulator back to DOS
SOURCE CODE
===========
The software was originally developed to be compiled with Turbo Pascal's
TASM assembler and then linked with TLINK to produce an EXE binary under a
DOS environment. The original work has been converted to NASM (8086) format
for future development work and can be developed under a Unix environment.
The conversion process used the NOMYSO V4.0 MASM/TASM to NASM source
converter available here:
www.devoresoftware.com/nomyso
The sources required some changes by hand afterwards. Comparing of the
original compiled/linked executable to that produced by NASM and TLINK/ALINK
is not really possible as different opcodes for some instructions are used
and optimising differences exist. TASM (v3.2) does not appear to have
anyway of turning optimisation off and there are other areas where the
optimisation does not work consistently.
z80em86 Source Files
--------------------
arith8.asm 8-bit Arithmetic and Logical Group
arith16.asm 16-bit Arithmetic Group
bit.asm Bit Test Group
call.asm Call and Return Group
control.asm General Purpose Arithmetic and CPU Control Groups
exchange.asm Exchange, Block Transfer, Block Search Groups
io.asm Input and Output Group
jump.asm Jump Group
load8.asm 8-bit Load Group
load16.asm 16-bit Load Group
res.asm Bit Reset Group
rotate.asm Rotate and Shift Group
set.asm Bit Set Group
insthand.asm Instruction Handler for Extended Opcodes
macros.asm Macros
table.asm Z80 Opcodes and Function Interface tables
function.asm General function interface support for Z80 system code
hardware.asm Hardware interface support for Z80 system code
main.asm Main assembly module
video.asm Video function support for Z80 system code
window.asm Window and Screen Output support for error messages
Utility Source Files
--------------------
z80hdd.pas A Turbo Pascal program that can be used to create a 4MB
formatted HDD disk image.
Code Execution
--------------
Code execution commences in 'main.asm' at '..start'
Z80 Source Opcode Labels
------------------------
The labels used are 6 character maximum which was common at the time as it
fitted neatly in the first tab column of 8 spaces.
Label format for Z80 opcodes:
ABC
A - All labels that reference a Z80 instruction commence with 'Z_'
B - The capital letters that follow is the mnemonic.
C - operand associated with mnemonic as follows:-
a=reg A
b=reg B bc=reg BC
c=reg C
d=reg D de=reg DE
e=reg E
h=reg H hl=reg HL x=reg IX y=reg IY z=(HL) w=(IX) v=(IY)
l=reg L
f=reg F sp=reg SP n=$12 n=$1234 m=($1234)
i=reg I
r=reg R
Tesing z80em86
==============
In recent times a CP/M program 'zexdoc.com' has been used for testing and
debugging emulation. 'zexdoc.com' is the documented Z80 flags version of
'zexall.com' but both versions test undocumented instructions.
The 'zexdoc' source code was modified to disable tests where undocumented
instructions were used as these caused the emulator to stop. 'zexdoc.com'
passed all the tests for undocumented instructions. The disabled tests may
contain documented instructions and as such will not be tested.
The source file (CPM.zip) came from here:
http://mdfs.net/Software/Z80/Exerciser/
The following tests were disabled as undocumented instructions are included
in the tests. Place a semicolon in front of these and recompile:
alu8rx, incxh, incxl, incyh, incyl, ld8ixy, ld8rrx, rotxy, rotz80
These all passed the test (no CRC errors):
adc16, add16, add16x, add16y, alu8i, alu8r, alu8x, bitx, bitz80, cpd1, cpi1,
daaop, inca, incb, incbc, incc, incd, incde, ince, inch, inchl, incix, inciy,
incl, incm, incsp, incx, ld161, ld162, ld163, ld164, ld165, ld166, ld167,
ld168, ld16im, ld16ix, ld8bd, ld8im, ld8imx, ld8ix1, ld8ix2, ld8ix3, ld8rr,
lda, ldd1, ldd2, ldi1, ldi2, negop, rldop, rot8080, srz80, srzx, st8ix1,
st8ix2, st8ix3, stabd
Output from running the tests
-----------------------------
Execution times to complete the tests on various hardware/systems:
* Athlon XP 1.8GHz (2200+) PC, W2000 Pro 'cmd' prompt: 55 seconds.
* Athlon XP 1.8GHz (2200+) PC, W98 'Startup disk': 47 seconds.
* Linux Athlon AMD64 dual core (3800+), 32 bit Linux and DosEmu: 227 seconds.
Z80doc instruction exerciser
<adc,sbc> hl,<bc,de,hl,sp>.... OK
add hl,<bc,de,hl,sp>.......... OK
add ix,<bc,de,ix,sp>.......... OK
add iy,<bc,de,iy,sp>.......... OK
aluop a,nn.................... OK
aluop a,<b,c,d,e,h,l,(hl),a>.. OK
aluop a,(<ix,iy>+1)........... OK
bit n,(<ix,iy>+1)............. OK
bit n,<b,c,d,e,h,l,(hl),a>.... OK
cpd<r>........................ OK
cpi<r>........................ OK
<daa,cpl,scf,ccf>............. OK
<inc,dec> a................... OK
<inc,dec> b................... OK
<inc,dec> bc.................. OK
<inc,dec> c................... OK
<inc,dec> d................... OK
<inc,dec> de.................. OK
<inc,dec> e................... OK
<inc,dec> h................... OK
<inc,dec> hl.................. OK
<inc,dec> ix.................. OK
<inc,dec> iy.................. OK
<inc,dec> l................... OK
<inc,dec> (hl)................ OK
<inc,dec> sp.................. OK
<inc,dec> (<ix,iy>+1)......... OK
ld <bc,de>,(nnnn)............. OK
ld hl,(nnnn).................. OK
ld sp,(nnnn).................. OK
ld <ix,iy>,(nnnn)............. OK
ld (nnnn),<bc,de>............. OK
ld (nnnn),hl.................. OK
ld (nnnn),sp.................. OK
ld (nnnn),<ix,iy>............. OK
ld <bc,de,hl,sp>,nnnn......... OK
ld <ix,iy>,nnnn............... OK
ld a,<(bc),(de)>.............. OK
ld <b,c,d,e,h,l,(hl),a>,nn.... OK
ld (<ix,iy>+1),nn............. OK
ld <b,c,d,e>,(<ix,iy>+1)...... OK
ld <h,l>,(<ix,iy>+1).......... OK
ld a,(<ix,iy>+1).............. OK
ld <bcdehla>,<bcdehla>........ OK
ld a,(nnnn) / ld (nnnn),a..... OK
ldd<r> (1).................... OK
ldd<r> (2).................... OK
ldi<r> (1).................... OK
ldi<r> (2).................... OK
neg........................... OK
<rrd,rld>..................... OK
<rlca,rrca,rla,rra>........... OK
<set,res> n,<bcdehl(hl)a>..... OK
<set,res> n,(<ix,iy>+1)....... OK
ld (<ix,iy>+1),<b,c,d,e>...... OK
ld (<ix,iy>+1),<h,l>.......... OK
ld (<ix,iy>+1),a.............. OK
ld (<bc,de>),a................ OK
Tests complete
Z80 Operating systems
=====================
This emulator project does not provide any sort of operating system. It
simply emulates a Z80 CPU and provides some hardware support that may be
used by an operating system.
The emulator on start-up will load a boot sector from a floppy disk or HDD
disk image and execute the code loaded. What code is loaded and run is
determined by the user and what code is on the disk.
I have coded a customised CP/M 3 BIOS and CP/M 3 support utilities that have
been designed to run under this emulator. The system may be booted in
banked or non banked mode. Further information about the system can be
found in the CP/M 3 package.
This README file should provide all the information needed for anyone to
write other systems to be run under the emulator.
The CP/M 3 system and support files are available as a single package from
here:
http://www.cpm.z80.de/source.html
http://www.gaby.de/z80/z80emu.htm
Links
=====
- The Unofficial CP/M Web site
http://www.cpm.z80.de
- Walnut Creek CDROM, contains a lot of CP/M stuff
http://z80cpu.eu/mirrors/oldcomputers.dyndns.org/cdrom/cpm
- Other sites:
http://www.digitalresearch.biz/CPM.HTM
http://www.classiccmp.org/dunfield/
http://www.seasip.demon.co.uk/Unix/LibDsk/
http://www.seasip.demon.co.uk/Cpm/index.html
http://www.znode51.de/indexe.htm
http://www.z80.eu/cpmcomp.html
Projects by this author
=======================
uBee512
-------
An emulator for the Microbee Z80 ROM, FDD and HDD based models.
http://www.microbee-mspp.org.au/public_repository
uBeeDisk
--------
A tool for converting disks/images from one to another with
auto detection options for Microbee disks.
http://www.microbee-mspp.org.au/public_repository
z80em86
-------
A Z80 CPU emulator coded in Intel 86 assembly language.
http://www.cpm.z80.de/source.html
http://www.gaby.de/z80/z80emu.htm
Contact
=======
If you have any new feature suggestions, bug reports, etc. then please send
an email to: ubee512@gmail.com
Please state which project your referring to.
Stewart

View File

@@ -0,0 +1,22 @@
Distribution License
====================
See doc\GPL\COPYING for the GPL v2 license in detail.
z80em86 GPL
-----------
z80em86 - A Z80 CPU emulator coded in Intel 86 assembly language.
Copyright (C) 1992-2009 Stewart Kay
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA