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

View File

@@ -0,0 +1,147 @@
#!/bin/bash
#
# Script to optionally download, modify and build the 'alink' v1.6 linker
# under Unix. The web page for the linker is here:
#
# http://alink.sourceforge.net/
#
# usage:
# $build_alink build_directory package_directory url
#
# build_directory:
# A directory to extract the package files to and build. The directory will
# be created if it does not already exist. (Note: files are not in a
# directory when unzipped)
#
# package_directory:
# The location of the package. This location if it does exist will be
# created and a package downloaded from the Internet if the 3rd parameter
# url is specified.
#
# url:
# Specify an optional url download location. If not specified then the
# package file already in the package_directory will be used. If specified
# then downloading only occurs if the required package is not already in
# package_directory.
#
# SJK 14 Feb 09
APP_DIR=$1
URL=$3
# Check that a build directory location has been specified
if [ "$APP_DIR" = "" ]; then
echo "$0 : A build directory must be specified"
exit 1
fi
# Check that a package directory location has been specified
if [ "$2" = "" ]; then
echo "$0 : A package directory must be specified"
exit 1
fi
# Check if we have a build directory and exit if the 'alink' binary file
# already exists. If not create the directory, optionally download, modify
# and build the package.
if (test -d $APP_DIR); then
if (test -f $APP_DIR/alink); then
echo "'alink' binary exists. To rebuild remove it or the build directory."
exit 0
fi
else
mkdir $APP_DIR
fi
# Create the package directory if downloading and does not already exist
if (test ! -d $2 ); then
if [ "$URL" != "" ]; then
mkdir $2
else
echo "$0 : Package directory not found"
exit 1
fi
fi
# Get absolute paths to directories
CWD=$PWD
cd $2
PKGDIR=$PWD
cd $CWD
# Download the package if we don't already have it
if (test ! -f $PKGDIR/alinksrc.zip); then
if [ "$URL" != "" ]; then
cd $PKGDIR
echo "$0 : Downloading: $URL"
wget $URL
cd $CWD
else
echo "$0 : Package file does not exist"
exit 1
fi
fi
# Change to the build directory
cd $APP_DIR
# Extract all files (with overwrite) forcing names to lower case
unzip -LL -o $PKGDIR/alinksrc.zip
# Check this is version 1.6 of the package
TESTSTR=`grep 'ALINK v1.6 (C)' alink.c`
if [ "$TESTSTR" = "" ]; then
echo "$0 : Error - this script is only intended for v1.6 of ALINK"
exit 1
fi
# Create a new Makefile for Unix (note escaped dollar characters)
rm Makefile_unix
cat >> Makefile_unix << EOT
%.o: %.c
gcc -c -o \$@ $<
all: alink
alink.o combine.o util.o output.o objload.o coff.o cofflib.o : alink.h
alink: alink.o combine.o util.o output.o objload.o coff.o cofflib.o
gcc -o \$@ $^
EOT
# Append this to the alink.h file
cat >> alink.h << EOT
/* Added SJK 14 Feb 09 */
#ifdef __unix__
#ifndef alink_mod
#define alink_mod
#define stricmp strcasecmp
#define strupr xstrupr
/* strdup got redefined! put this back to strdup */
#define _strdup strdup
char *xstrupr (char *a);
#endif
#endif
EOT
# Append this to the util.c file
cat >> util.c << EOT
/* Added SJK 14 Feb 09 */
#ifdef __unix__
char *xstrupr (char *a)
{
char *ret = a;
while (*a)
{
if (islower(*a))
*a = toupper(*a);
++a;
}
return ret;
}
#endif
EOT
# Compile the program
make -f Makefile_unix

View File

@@ -0,0 +1,218 @@
#*******************************************************************************
#* z80em86 Makefile *
#* A Z80 CPU emulator coded in Intel 86 assembly language *
#* *
#* Copyright (C) 1992-2009 Stewart Kay *
#*******************************************************************************
#
#===============================================================================
# REVISION HISTORY (Most recent at top)
#===============================================================================
# v1.0.0 - S.J.Kay 13/2/2009
# --------------------------
# Created initial Makefile.
#
#===============================================================================
# How to use this GNU make file.
#===============================================================================
# make help will show the options available.
#
#===============================================================================
# Requirements
#===============================================================================
# Requirements:
# - NASM assembler (Netwide Assembler)
# - ALINK cross linker (will be downloaded and built during the make process)
#===============================================================================
# Overrides
#===============================================================================
.SUFFIXES:
TOPDIR=..
#===============================================================================
# Application specific definitions
#===============================================================================
APP=z80em86
VERSION=1.0.1
TITLE=z80em86
# Set the debugging level
OPT_DEBUG=0
# Values passed as defines when compiling
APPVER=\"$(VERSION)\"
APPIDSTR=\"$(APP)\"
# Object files
OBJA=./arith16.obj ./bit.obj ./control.obj ./function.obj ./insthand.obj
OBJA+=./jump.obj ./load8.obj ./main.obj ./rotate.obj ./table.obj ./window.obj
OBJA+=./arith8.obj ./call.obj ./exchange.obj ./hardware.obj ./io.obj ./load16.obj
OBJA+=./macros.obj ./res.obj ./set.obj ./video.obj
# Dependencies
DEPENDENCIES=macros.asm Makefile
HAVE_DOSEMU=$(wildcard ~/.dosemu/drive_c)
Z80HDD=~/.dosemu/drive_c/$(APP)/z80hdd.exe
#===============================================================================
# Cross compile and link.
#
# -O2 is needed to optimise code like TASM does, there does not appear to be a
# way to turn it off in TASM.
#===============================================================================
XOBJA=$(OBJA:./%=build/%)
LOBJA=$(XOBJA:%.obj=%.lst)
ifeq ($(OPT_DEBUG),1)
DEBUG=
OPT=
else
DEBUG=
OPT=-O2
endif
NASM=nasm
LINK=../alink/alink
AFLAGS=$(DEBUG) $(OPT) -f obj
AINC=
ALIB=
ADEF=-DAPPVER=$(APPVER) -DAPPIDSTR=$(APPIDSTR)
build/$(APP).exe: $(LINK) $(XOBJA) $(Z80HDD)
$(LINK) $(XOBJA) -o build/$(APP).exe -m
build/%.obj: %.asm $(DEPENDENCIES)
@[ -d build ] || mkdir build
$(NASM) $(AFLAGS) $(ADEF) $(*).asm -o build/$(*).obj -l build/$(*).lst
$(LINK):
sh ../scripts/build_alink.sh ../alink ../temp \
http://alink.sourceforge.net/files/alinksrc.zip
ifneq ($(HAVE_DOSEMU),)
$(Z80HDD): z80hdd.pas
@[ -d ~/.dosemu/drive_c/$(APP) ] || mkdir ~/.dosemu/drive_c/$(APP)
cp z80hdd.pas ~/.dosemu/drive_c/$(APP)
dosemu -dumb "cd $(APP)|tpc z80hdd.pas"
cp ~/.dosemu/drive_c/$(APP)/z80hdd.exe build/
else
$(Z80HDD):
@echo "No '~/.dosemu/drive_c/' dosemu home account was located"
@echo "Can't create Z80HDD.EXE"
endif
#===============================================================================
# General maintenance
#===============================================================================
clean:
rm -f $(XOBJA) $(LOBJA) build/$(APP).exe build/$(APP).map \
$(TOPDIR)/distributions/$(APP)-$(VERSION).tar.gz \
$(TOPDIR)/distributions/$(APP)-$(VERSION)-dos.zip \
$(Z80HDD)
cleanall: clean
rm -Rf build/
rm -Rf $(LINK)
#===============================================================================
# Install and remove installed files
#===============================================================================
ifneq ($(HAVE_DOSEMU),)
install:
@[ -d ~/.dosemu/drive_c/$(APP) ] || mkdir ~/.dosemu/drive_c/$(APP)
cp build/$(APP).exe ~/.dosemu/drive_c/$(APP)/
uninstall:
rm ~/.dosemu/drive_c/$(APP)/$(APP).exe
else
install:
@echo "No '~/.dosemu/drive_c/' dosemu home account was located"
uninstall:
@echo "No '~/.dosemu/drive_c/' dosemu home account was located"
endif
#===============================================================================
# Run the program under dosemu.
#
# A bootable Z80HDD.DSK image is required in '~/.dosemu/drive_c/z80em86/'
# for non floppy drive booting and is the default unless a floppy drive is
# specified.
#
# If the Z80HDD.DSK is not found the user will be prompted for a floppy
# disk in drive A:
#===============================================================================
HAVE_INSTALL=$(wildcard ~/.dosemu/drive_c/$(APP)/$(APP).exe)
ifneq ($(HAVE_INSTALL),)
run:
dosemu "cd $(APP)|z80em86"
runa:
dosemu "cd $(APP)|z80em86 -a"
runb:
dosemu "cd $(APP)|z80em86 -b"
else
run:
@echo "$(APP).exe has not been installed"
runa:
@echo "$(APP).exe has not been installed"
runb:
@echo "$(APP).exe has not been installed"
endif
#===============================================================================
# Help
#===============================================================================
help:
@echo "This is the $(APP) v$(VERSION) Z80 emulator GNU makefile"
@echo ""
@echo "Specify one of the following:"
@echo "make cross compiled DOS build"
@echo "make clean removes build and distribution files"
@echo "make cleanall cleans and removes alink generated files"
@echo "make install install files under dosemu"
@echo "make uninstall uninstall files under dosemu"
@echo "make run run booting Z80HDD.DSK under dosemu"
@echo "make runa run forcing booting A: under dosemu"
@echo "make runb run forcing booting B: under dosemu"
@echo "make help this help information"
@echo ""
@echo "Packaging system only:"
@echo "make srcdist make source distribution"
@echo "make alldist make source and DOS binary distribution"
@echo "make doszipdist make DOS ZIP binary distribution"
@echo "make upload upload distribution packages"
#===============================================================================
# Create source distribution.
#===============================================================================
srcdist:
cd $(TOPDIR) && make srcdist V=$(VERSION)
#===============================================================================
# Create all distributions.
#===============================================================================
alldist:
cd $(TOPDIR) && make alldist V=$(VERSION)
#===============================================================================
# Create a DOS binary ZIP file distribution.
#===============================================================================
doszipdist:
cd $(TOPDIR) && make doszipdist V=$(VERSION)
#===============================================================================
# Upload all the distribution files.
#===============================================================================
upload:
cd $(TOPDIR) && make upload_to_sf V=$(VERSION)

View File

@@ -0,0 +1,470 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* 16-bit Arithmetic Group *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_ADxbc, Z_ADxde, Z_INCx, Z_ADxx, Z_DECx
GLOBAL Z_ADxsp
GLOBAL Z_ADybc, Z_ADyde, Z_INCy, Z_ADyy, Z_DECy
GLOBAL Z_ADysp
GLOBAL Z_SChlbc, Z_AChlbc, Z_SChlde, Z_AChlde
GLOBAL Z_SChlhl, Z_AChlhl, Z_SChlsp, Z_AChlsp
GLOBAL Z_INCbc, Z_INCde, Z_INChl, Z_DECbc, Z_DECde, Z_DEChl
GLOBAL Z_INCsp, Z_DECsp
GLOBAL Z_ADhlbc, Z_ADhlde, Z_ADhlhl, Z_ADhlsp
; declared in INSTHAND.ASM
EXTERN Z80IX, Z80IY, Z80SP, FlagN
%include "macros.asm"
;***********************************************************
;* ADD HL,BC Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADhlbc:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
add bx,cx
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADD HL,DE Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADhlde:
mov BYTE [FlagN],0
mov di,cx ;save value in reg CX
lahf
and ah,11111110b
mov ch,ah
add bx,dx
lahf
and ah,00000001b
or ah,ch
mov cx,di ;restore value to reg CX
XinstB
;***********************************************************
;* ADD HL,HL Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADhlhl:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
add bx,bx
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADD HL,SP Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADhlsp:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
add bx,[Z80SP]
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADD IX,BC Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADxbc:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
add [Z80IX],cx
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADD IX,DE Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADxde:
mov BYTE [FlagN],0
mov di,cx ;save value in reg CX
lahf
and ah,11111110b
mov ch,ah
add [Z80IX],dx
lahf
and ah,00000001b
or ah,ch
mov cx,di ;restore value to reg CX
XinstB
;***********************************************************
;* ADD IX,IX Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADxx:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
mov si,[Z80IX]
add [Z80IX],si
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADD IX,SP Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADxsp:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
mov si,[Z80SP]
add [Z80IX],si
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADD IY,BC Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADybc:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
add [Z80IY],cx
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADD IY,DE Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADyde:
mov BYTE [FlagN],0
mov di,cx ;save value in reg CX
lahf
and ah,11111110b
mov ch,ah
add [Z80IY],dx
lahf
and ah,00000001b
or ah,ch
mov cx,di ;restore value to reg CX
XinstB
;***********************************************************
;* ADD IY,IY Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADyy:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
mov si,[Z80IY]
add [Z80IY],si
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADD IY,SP Flags: S Z - H - P/V N C *
;* . . x x x . 0 ^ *
;***********************************************************
Z_ADysp:
mov BYTE [FlagN],0
mov di,dx ;save value in reg DX
lahf
and ah,11111110b
mov dh,ah
mov si,[Z80SP]
add [Z80IY],si
lahf
and ah,00000001b
or ah,dh
mov dx,di ;restore value to reg DX
XinstB
;***********************************************************
;* ADC HL,BC Flags: S Z - H - P/V N C *
;* ^ ^ x x x V 0 ^ *
;***********************************************************
Z_AChlbc:
mov BYTE [FlagN],0
adc bx,cx
jo achlbc
XinstC
achlbc: XinstD
;***********************************************************
;* ADC HL,DE Flags: S Z - H - P/V N C *
;* ^ ^ x x x V 0 ^ *
;***********************************************************
Z_AChlde:
mov BYTE [FlagN],0
adc bx,dx
jo achlde
XinstC
achlde: XinstD
;***********************************************************
;* ADC HL,HL Flags: S Z - H - P/V N C *
;* ^ ^ x x x V 0 ^ *
;***********************************************************
Z_AChlhl:
mov BYTE [FlagN],0
adc bx,bx
jo achlhl
XinstC
achlhl: XinstD
;***********************************************************
;* ADC HL,SP Flags: S Z - H - P/V N C *
;* ^ ^ x x x V 0 ^ *
;***********************************************************
Z_AChlsp:
mov BYTE [FlagN],0
adc bx,[Z80SP]
jo achlsp
XinstC
achlsp: XinstD
;***********************************************************
;* SBC HL,BC Flags: S Z - H - P/V N C *
;* ^ ^ x x x V 1 ^ *
;***********************************************************
Z_SChlbc:
mov BYTE [FlagN],2
sbb bx,cx
jo schlbc
XinstC
schlbc: XinstD
;***********************************************************
;* SBC HL,DE Flags: S Z - H - P/V N C *
;* ^ ^ x x x V 1 ^ *
;***********************************************************
Z_SChlde:
mov BYTE [FlagN],2
sbb bx,dx
jo schlde
XinstC
schlde: XinstD
;***********************************************************
;* SBC HL,HL Flags: S Z - H - P/V N C *
;* ^ ^ x x x V 1 ^ *
;***********************************************************
Z_SChlhl:
mov BYTE [FlagN],2
sbb bx,bx
jo schlhl
XinstC
schlhl: XinstD
;***********************************************************
;* SBC HL,SP Flags: S Z - H - P/V N C *
;* ^ ^ x x x V 1 ^ *
;***********************************************************
Z_SChlsp:
mov BYTE [FlagN],2
sbb bx,[Z80SP]
jo schlsp
XinstC
schlsp: XinstD
;***********************************************************
;* INC BC Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_INCbc:
lahf
inc cx
XinstB
;***********************************************************
;* INC DE Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_INCde:
lahf
inc dx
XinstB
;***********************************************************
;* INC HL Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_INChl:
lahf
inc bx
XinstB
;***********************************************************
;* INC SP Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_INCsp:
lahf
inc WORD [Z80SP]
XinstB
;***********************************************************
;* INC IX Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_INCx:
lahf
inc WORD [Z80IX]
XinstB
;***********************************************************
;* INC IY Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_INCy:
lahf
inc WORD [Z80IY]
XinstB
;***********************************************************
;* DEC BC Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_DECbc:
lahf
dec cx
XinstB
;***********************************************************
;* DEC DE Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_DECde:
lahf
dec dx
XinstB
;***********************************************************
;* DEC HL Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_DEChl:
lahf
dec bx
XinstB
;***********************************************************
;* DEC SP Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_DECsp:
lahf
dec WORD [Z80SP]
XinstB
;***********************************************************
;* DEC IX Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_DECx:
lahf
dec WORD [Z80IX]
XinstB
;***********************************************************
;* DEC IY Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_DECy:
lahf
dec WORD [Z80IY]
XinstB
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,354 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Call and Return Group *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed 'lea' instructions to 'mov'.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 28 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_RETN, Z_RETI
GLOBAL Z_RETNZ, Z_RETZ, Z_RET, Z_RETNC, Z_RETC
GLOBAL Z_RETPO, Z_RETPE, Z_RETP, Z_RETM
GLOBAL Z_CALLNZ, Z_CALLZ, Z_CALL, Z_CALLNC, Z_CALLC
GLOBAL Z_CALLPO, Z_CALLPE, Z_CALLP, Z_CALLM
GLOBAL Z_RST0, Z_RST1, Z_RST2, Z_RST3
GLOBAL Z_RST4, Z_RST5, Z_RST6, Z_RST7
; declared in FUNCTION.ASM
EXTERN Nocde0
; declared in INSTHAND.ASM
EXTERN Z80SP
%include "macros.asm"
;***********************************************************
;* CALL NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALL:
mov di,[Z80SP]
mov si,bp
lahf
dec di
dec di
inc si
inc si
mov [Z80SP],di
mov word [es:Z80+di],si
mov bp,word [es:Z80+bp]
XinstB
;***********************************************************
;* CALL NZ,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALLNZ:
jnz callnz
lahf
inc bp
inc bp
XinstB
callnz: jmp Z_CALL
;***********************************************************
;* CALL Z,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALLZ:
jz callz
lahf
inc bp
inc bp
XinstB
callz: jmp Z_CALL
;***********************************************************
;* CALL NC,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALLNC:
jnc callnc
lahf
inc bp
inc bp
XinstB
callnc: jmp Z_CALL
;***********************************************************
;* CALL C,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALLC:
jc callc
lahf
inc bp
inc bp
XinstB
callc: jmp Z_CALL
;***********************************************************
;* CALL PO,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALLPO:
jpo callpo
lahf
inc bp
inc bp
XinstB
callpo: jmp Z_CALL
;***********************************************************
;* CALL PE,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALLPE:
jpe callpe
lahf
inc bp
inc bp
XinstB
callpe: jmp Z_CALL
;***********************************************************
;* CALL P,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALLP:
jns callp
lahf
inc bp
inc bp
XinstB
callp: jmp Z_CALL
;***********************************************************
;* CALL M,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_CALLM:
js callm
lahf
inc bp
inc bp
XinstB
callm: jmp Z_CALL
;***********************************************************
;* RET Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RET:
mov si,[Z80SP]
mov bp,word [es:Z80+si]
lahf
inc si
inc si
mov [Z80SP],si
XinstB
;***********************************************************
;* RET NZ Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETNZ:
jnz retnz
XinstA
retnz: jmp Z_RET
;***********************************************************
;* RET Z Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETZ:
jz retz
XinstA
retz: jmp Z_RET
;***********************************************************
;* RET NC Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETNC:
jnc retnc
XinstA
retnc: jmp Z_RET
;***********************************************************
;* RET C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETC:
jc retc
XinstA
retc: jmp Z_RET
;***********************************************************
;* RET PO Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETPO:
jpo retpo
XinstA
retpo: jmp Z_RET
;***********************************************************
;* RET PE Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETPE:
jpe retpe
XinstA
retpe: jmp Z_RET
;***********************************************************
;* RET P Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETP:
jns retp
XinstA
retp: jmp Z_RET
;***********************************************************
;* RET M Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETM:
js retm
XinstA
retm: jmp Z_RET
;***********************************************************
;* RETI Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETI:
mov si,reti_
jmp NEAR Nocde0
reti_: db 'RETI$'
;***********************************************************
;* RETN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RETN:
mov si,retn_
jmp NEAR Nocde0
retn_: db 'RETN$'
;***********************************************************
;* RST 0 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RST0:
mov si,0000h
restor: mov di,[Z80SP]
lahf
dec di
dec di
mov [Z80SP],di
mov word [es:Z80+di],bp
mov bp,si
XinstB
;***********************************************************
;* RST 1 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RST1:
mov si,0008h
jmp restor
;***********************************************************
;* RST 2 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RST2:
mov si,0010h
jmp restor
;***********************************************************
;* RST 3 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RST3:
mov si,0018h
jmp restor
;***********************************************************
;* RST 4 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RST4:
mov si,0020h
jmp restor
;***********************************************************
;* RST 5 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RST5:
mov si,0028h
jmp restor
;***********************************************************
;* RST 6 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RST6:
mov si,0030h
jmp restor
;***********************************************************
;* RST 7 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RST7:
mov si,0038h
jmp restor
end

View File

@@ -0,0 +1,208 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* General Purpose Arithmetic and CPU Control Groups *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 25 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed 'lea' instructions to 'mov'.
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
; - Fixed DAA instruction to give the correct half carry flag result.
; - The CCF instruction (Z_CCF) code required changes as the Zilog data book
; was incorrect concerning the 'H' flag.
;
; v1.00 - 28 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_IM0, Z_IM1, Z_IM2, Z_DI, Z_EI, Z_HALT
GLOBAL Z_DAA, Z_CPL, Z_NEG, Z_SCF, Z_CCF, Z_NOP
; declared in FUNCTION.ASM
EXTERN Nocde0, Nocde1
; declared in INSTHAND.ASM
EXTERN IFF, FlagN
%include "macros.asm"
;***********************************************************
;* DAA Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x P . ^ *
;***********************************************************
Z_DAA:
mov [temp1],al ;keep track of bit 4
lahf
mov si,ax ;save ah (orig flags)
and ah,00000001b ;save the carry flag
cmp al,99h
jbe daa0 ;if below or equal
mov ah,00000001b ;set the carry flag
daa0: mov [temp2],ah
mov ax,si ;get back ah (orig flags)
cmp BYTE [FlagN],2
jz daa1
sahf
daa
lahf
and ah,11101110b ;clear both carry flags
xor [temp1],al ;if bit 4 changed then H=1
and BYTE [temp1],00010000b ;keep the half carry flag
or ah,BYTE [temp1] ;add in half carry flag
or ah,BYTE [temp2] ;add in carry flag
XinstB
daa1: sahf
das
lahf
and ah,11101110b ;clear both carry flags
xor [temp1],al ;if bit 4 changed then H=1
and BYTE [temp1],00010000b ;keep the half carry flag
or ah,BYTE [temp1] ;add in half carry flag
or ah,BYTE [temp2] ;add in carry flag
XinstB
temp1 resb 1
temp2 resb 1
;***********************************************************
;* CPL Flags: S Z - H - P/V N C *
;* . . x 1 x . 1 . *
;***********************************************************
Z_CPL:
lahf
not al
or ah,00010000b ;set the half carry flag
mov BYTE [FlagN],2
XinstB
;***********************************************************
;* NEG Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x V 1 ^ *
;***********************************************************
Z_NEG:
neg al
mov BYTE [FlagN],2
jo neg_
XinstC
neg_: XinstD
;***********************************************************
;* CCF Flags: S Z - H - P/V N C *
;* . . x ^ x . 0 ^ *
;***********************************************************
Z_CCF:
cmc
mov BYTE [FlagN],0
lahf
jc ccf_
or ah,00010000b ;set the half carry flag
XinstB
ccf_: and ah,11101111b ;clear the half carry flag
XinstB
;***********************************************************
;* SCF Flags: S Z - H - P/V N C *
;* . . x 0 x . 0 1 *
;***********************************************************
Z_SCF:
stc
mov BYTE [FlagN],0
lahf
and ah,11101111b ;clear the half carry flag
XinstB
;***********************************************************
;* NOP Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_NOP:
XinstA
;***********************************************************
;* HALT Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_HALT:
mov si,halt
jmp NEAR Nocde1
halt: db 'HALT$'
;***********************************************************
;* DI Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_DI:
mov BYTE [IFF],0
XinstA
;***********************************************************
;* EI Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_EI:
mov BYTE [IFF],4
XinstA
;***********************************************************
;* IM 0 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_IM0:
mov si,im0
jmp NEAR Nocde0
im0: db 'IM 0$'
;***********************************************************
;* IM 1 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_IM1:
mov si,im1
jmp NEAR Nocde0
im1: db 'IM 1$'
;***********************************************************
;* IM 2 Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_IM2:
mov si,im2
jmp NEAR Nocde0
im2: db 'IM 2$'
end

View File

@@ -0,0 +1,277 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Exchange, Block Transfer, Block Search Groups *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_EXafaf, Z_EXX, Z_EXsphl, Z_EXdehl, Z_EXspx, Z_EXspy
GLOBAL Z_CPI, Z_CPD, Z_CPIR, Z_CPDR
GLOBAL Z_LDI, Z_LDD, Z_LDIR, Z_LDDR
; declared in INSTHAND.ASM
EXTERN Z80SP, Z80IX, Z80IY
EXTERN Z80AF, Z80BC, Z80DE, Z80HL
EXTERN FlagN, FlagNx
%include "macros.asm"
tempb1 resb 1
;***********************************************************
;* EX DE,HL Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_EXdehl:
xchg dx,bx
XinstA
;***********************************************************
;* EXX AF,AF' Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_EXafaf:
mov ah,[FlagN]
xchg ah,[FlagNx]
mov [FlagN],ah
lahf
xchg ax,[Z80AF]
XinstB
;***********************************************************
;* EXX Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_EXX:
xchg cx,[Z80BC]
xchg dx,[Z80DE]
xchg bx,[Z80HL]
XinstA
;***********************************************************
;* EX (SP),HL Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_EXsphl:
mov di,[Z80SP]
xchg bx,word [es:Z80+di]
XinstA
;***********************************************************
;* EX (SP),IX Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_EXspx:
mov di,[Z80SP]
mov si,[Z80IX]
xchg si,word [es:Z80+di]
mov [Z80IX],si
XinstA
;***********************************************************
;* EX (SP),IY Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_EXspy:
mov di,[Z80SP]
mov si,[Z80IY]
xchg si,word [es:Z80+di]
mov [Z80IY],si
XinstA
;***********************************************************
;* LDI Flags: S Z - H - P/V N C *
;* . . x 0 x ^ 0 . *
;***********************************************************
Z_LDI:
mov BYTE [FlagN],0
mov ah,[es:Z80+bx] ;source in HL
mov di,dx ;destination in DE
mov BYTE [es:Z80+di],ah
lahf
inc bx
inc dx
dec cx
and ah,11101011b ;lose half carry and parity flag
jcxz ldi
or ah,00000100b ;set parity flag (BC <> 0)
ldi: XinstB
;***********************************************************
;* LDIR Flags: S Z - H - P/V N C *
;* . . x 0 x 0 0 . *
;***********************************************************
Z_LDIR:
lahf
mov si,bx ;source in HL
mov di,dx ;destination in DE
push ds
push es
pop ds
cld
rep movsb ;move memory
pop ds
mov bx,si
mov dx,di
and ah,11101011b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* LDD Flags: S Z - H - P/V N C *
;* . . x 0 x ^ 0 . *
;***********************************************************
Z_LDD:
mov BYTE [FlagN],0
mov ah,[es:Z80+bx] ;source in HL
mov di,dx ;destination in DE
mov BYTE [es:Z80+di],ah
lahf
dec bx
dec dx
dec cx
and ah,11101011b ;lose half carry and parity flag
jcxz ldd
or ah,00000100b ;set parity flag (BC <> 0)
ldd: XinstB
;***********************************************************
;* LDDR Flags: S Z - H - P/V N C *
;* . . x 0 x 0 0 . *
;***********************************************************
Z_LDDR:
lahf
mov si,bx ;source in HL
mov di,dx ;destination in DE
push ds
push es
pop ds
std
rep movsb ;move memory
pop ds
mov bx,si
mov dx,di
and ah,11101011b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* CPI Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x ^ 1 . *
;***********************************************************
Z_CPI:
lahf
and ah,00000001b ;save the carry flag
mov [tempb1],ah
mov BYTE [FlagN],2
cmp al,[es:Z80+bx] ;compare A=(HL)
lahf
inc bx
dec cx
and ah,11111010b ;lose the carry and parity flag
or ah,[tempb1] ;and replace with old carry flag
jcxz cpi
or ah,00000100b ;set parity flag (BC <> 0)
cpi: XinstB
;***********************************************************
;* CPIR Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x ^ 1 . *
;***********************************************************
Z_CPIR:
lahf
and ah,00000001b ;save the carry flag
mov [tempb1],ah
mov BYTE [FlagN],2
mov di,bx ;Z80 HL to DI reg
cld
repne scasb ;repeat until CX=0 or A=(HL)
mov bx,di ;DI reg TO Z80 HL
lahf
and ah,11111010b ;lose the carry and parity flag
or ah,[tempb1] ;and replace with old carry flag
jcxz cpir
or ah,00000100b ;set parity flag (BC <> 0)
cpir: XinstB
;***********************************************************
;* CPD Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x ^ 1 . *
;***********************************************************
Z_CPD:
lahf
and ah,00000001b ;save the carry flag
mov [tempb1],ah
mov BYTE [FlagN],2
cmp al,[es:Z80+bx] ;compare A=(HL)
lahf
dec bx
dec cx
and ah,11111010b ;lose the carry and parity flag
or ah,[tempb1] ;and replace with old carry flag
jcxz cpd
or ah,00000100b ;set parity flag (BC <> 0)
cpd: XinstB
;***********************************************************
;* CPDR Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x ^ 1 . *
;***********************************************************
Z_CPDR:
lahf
and ah,00000001b ;save the carry flag
mov [tempb1],ah
mov BYTE [FlagN],2
mov di,bx ;Z80 HL to DI reg
std
repne scasb ;repeat until CX=0 or A=(HL)
mov bx,di ;DI reg TO Z80 HL
lahf
and ah,11111010b ;lose the carry and parity flag
or ah,[tempb1] ;and replace with old carry flag
jcxz cpdr
or ah,00000100b ;set parity flag (BC <> 0)
cpdr: XinstB
end

View File

@@ -0,0 +1,679 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* General function interface support for Z80 system code *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 25 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed 'lea' instructions to 'mov'.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
; - Added code to display 4 opcodes at the PC when a trap occurs.
;
; v1.00 - 28 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL criter
GLOBAL fboot, SysErr
GLOBAL BufCnt, BootDr
GLOBAL fnc___, trp0__, trp1__
GLOBAL Nocde0, Nocde1, ReqAct, GtZseg
GLOBAL GetByt, SetByt
GLOBAL GtBoot
GLOBAL intfnc
GLOBAL blkcnt, blkget, blkput, blkfil
GLOBAL prmsta, prmget, vidsta, vidset
GLOBAL usrbyt, failed, rstz80, extemu
; declared in MAIN.ASM
EXTERN Z80res, Z80opc, Z80ext
EXTERN prmflg, vidoff, prmbuf
EXTERN BufSeg
; declared in WINDOW.ASM
EXTERN OpnWnd, ClsWnd, PrnStr
EXTERN PrnByt, PrnHex, GetAct
; declared in TABLE.ASM
EXTERN T0, Tx
; declared in HARDWARE.ASM
EXTERN Z80seg, Z80dma, cpycom
EXTERN sveoff, sveseg, sveamt, reqcpy
%include "macros.asm"
;===============================================================================
; DOS critical error handler
;===============================================================================
criter: sti ;turn interrupts back on
push ds
push es
push bx
push cx
push dx
push si
push di
push bp
push cs
pop ds ;address local data
mov dh,8 ;window Y start
mov dl,17 ;window X start
mov ch,16 ;window Y finish
mov cl,62 ;window X finish
call NEAR OpnWnd
add al,'A' ;drive letter if disk error
mov [ErrDrv],al ;place in error message
test ah,080h
mov dx,ErrMsB ;Type: disk error on drive X message
jz FndTyp
mov es,bp
test word [es:si+4],8000h
mov dx,ErrMsC ;Type: charater device message
jnz FndTyp
mov dx,ErrMsD ;Type: block device message
FndTyp: mov si,ErrMsA ;dos critical error message
call NEAR PrnStr
mov si,dx
call NEAR PrnStr ;display the error type
mov si,ErrMsE
call NEAR PrnStr ;Error: message
mov si,ErrMXX
mov bx,di
cmp bl,010h ;is error code in range ?
jnc shwerr
xor bh,bh
add bx,bx
mov si,[ErrTbl+bx]
shwerr: call NEAR PrnStr
mov si,ErrMsF ;Code: message
call NEAR PrnStr
mov bx,di
mov al,bl
call NEAR PrnHex ;print error number in hex
mov si,ErrMsG ;cr, lf, lf
call NEAR PrnStr
mov bx,ErrKey
test ah,010h ;retry response allowed ?
jz noretr
mov byte [bx],'R'
inc bx
mov si,ErrMsH ;retry message
call NEAR PrnStr
noretr: test ah,020h ;Ignore response allowed ?
jz noignr
mov byte [bx],'I'
inc bx
mov si,ErrMsI ;ignore message
call NEAR PrnStr
noignr: test ah,008h ;fail response allowed ?
jz nofail
mov byte [bx],'F'
inc bx
mov si,ErrMsJ ;fail message
call NEAR PrnStr
nofail: mov byte [bx],'$'
mov si,ErrMsK ;Action ? message
call NEAR PrnStr
mov si,ErrKey
call NEAR GetAct
cmp al,'R' ;retry action requested ?
mov ah,1 ;retry code
jz critex
cmp al,'I' ;ignore action requested ?
mov ah,0
jz critex
mov ah,3 ;fail code
critex: mov al,ah
call NEAR ClsWnd
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop es
pop ds
iret
ErrKey db '$$$$'
ErrTbl dw ErrM00, ErrM01, ErrM02, ErrM03, ErrM04, ErrM05, ErrM06, ErrM07
dw ErrM08, ErrM09, ErrM0A, ErrM0B, ErrM0C, ErrM0D, ErrM0E, ErrM0F
ErrMsA db ' DOS CRITICAL ERROR', 0dh, 0ah, '$'
ErrMsB db ' Type: Disk error on drive '
ErrDrv db ' ', 0dh, 0ah, '$'
ErrMsC db ' Type: Character device', 0dh, 0ah, '$'
ErrMsD db ' Type: Block device', 0dh, 0ah, '$'
ErrMsE db 'Error: $'
ErrMsF db ' Code: $'
ErrMsG db 0dh, 0ah, 0ah, '$'
ErrMsH db '[R]etry $'
ErrMsI db '[I]gnore $'
ErrMsJ db '[F]ail$'
ErrMsK db 0dh, 0ah, 'Action ?: $'
ErrM00 db 'Write-protect error', 0dh, 0ah, '$'
ErrM01 db 'Invalid drive number', 0dh, 0ah, '$'
ErrM02 db 'Drive not ready', 0dh, 0ah, '$'
ErrM03 db 'Unknown command requested', 0dh, 0ah, '$'
ErrM04 db 'Data error (CRC)', 0dh, 0ah, '$'
ErrM05 db 'Bad request structure length', 0dh, 0ah, '$'
ErrM06 db 'Seek error', 0dh, 0ah, '$'
ErrM07 db 'Unknown disk format', 0dh, 0ah, '$'
ErrM08 db 'Sector not found', 0dh, 0ah, '$'
ErrM09 db 'Printer out of paper', 0dh, 0ah, '$'
ErrM0A db 'Write fault', 0dh, 0ah, '$'
ErrM0B db 'Read fault', 0dh, 0ah, '$'
ErrM0C db 'General, non specific error', 0dh, 0ah, '$'
ErrM0D db 'UNDOCUMENTED ERROR 0D', 0dh, 0ah, '$'
ErrM0E db 'UNDOCUMENTED ERROR 0E', 0dh, 0ah, '$'
ErrM0F db 'Invalid disk change', 0dh, 0ah, '$'
ErrMXX db 'UNKNOWN ERROR', 0dh, 0ah, '$'
;===============================================================================
; Reset Z80 emulator
;===============================================================================
rstz80: pop ax ;discard near return address
pop ax ;discard Z80 reg PC
pop ax ;discard Z80 reg HL
pop ax ;discard Z80 reg DE
pop ax ;discard Z80 reg BC
jmp NEAR Z80res
;===============================================================================
; Exit from Z80 emulator to DOS
;===============================================================================
extemu: pop ax ;discard near return address
pop ax ;discard Z80 reg PC
pop ax ;discard Z80 reg HL
pop ax ;discard Z80 reg DE
pop ax ;discard Z80 reg BC
jmp NEAR Z80ext
;===============================================================================
; Failure to boot Z80 system disk
;===============================================================================
failed: pop ax ;discard near return address
pop ax ;discard Z80 reg PC
pop ax ;discard Z80 reg HL
pop ax ;discard Z80 reg DE
pop ax ;discard Z80 reg BC
fboot: mov dh,9 ;window Y start
mov dl,23 ;window X start
mov ch,14 ;window Y finish
mov cl,57 ;window X finish
call NEAR OpnWnd
mov si,BtfMsg
call NEAR PrnStr
jmp ActRE
;===============================================================================
; 1st byte of boot sector not $C3 (Z80 jump)
;===============================================================================
SysErr: mov dh,9 ;window Y start
mov dl,18 ;window X start
mov ch,15 ;window Y finish
mov cl,61 ;window X finish
call NEAR OpnWnd
mov si,SysMsg
call NEAR PrnStr
jmp ActRE
;===============================================================================
; Unsupported OUT (Fn),A code function
;===============================================================================
fnc___: pop ax ;discard near return address
pop ax ;discard Z80 reg PC
pop ax ;discard Z80 reg HL
pop ax ;discard Z80 reg DE
pop ax ;discard Z80 reg BC
dec bp
dec bp ;address of OUT (Fn),A code
mov dh,9 ;window Y start
mov dl,21 ;window X start
mov ch,15 ;window Y finish
mov cl,58 ;window X finish
call NEAR OpnWnd
mov si,FncMsg
jmp ShwPC
;===============================================================================
; Illegal OUT (Fn),A / 8086 INT function call
;===============================================================================
IntErr: pop ax ;discard near return address
pop ax ;discard Z80 reg PC
pop ax ;discard Z80 reg HL
pop ax ;discard Z80 reg DE
pop ax ;discard Z80 reg BC
dec bp
dec bp ;address of OUT (Fn),A code
mov dh,9 ;window Y start
mov dl,16 ;window X start
mov ch,15 ;window Y finish
mov cl,62 ;window X finish
call NEAR OpnWnd
mov si,IntMsg
jmp ShwPC
;===============================================================================
; Trap undocumented Z80 opcodes
;===============================================================================
trp0__: dec bp
dec bp
trp1__: dec bp
dec bp
mov dh,9 ;window Y start
mov dl,23 ;window X start
mov ch,15 ;window Y finish
mov cl,56 ;window X finish
call NEAR OpnWnd
mov si,OpcMsg
jmp ShwPC
;===============================================================================
; Trap non emulated Z80 opcodes
;===============================================================================
Nocde0: dec bp
Nocde1: dec bp
mov dh,9 ;window Y start
mov dl,19 ;window X start
mov ch,16 ;window Y finish
mov cl,59 ;window X finish
call NEAR OpnWnd
push si
mov si,CdeMsg
call NEAR PrnStr
pop si
;
ShwPC: call NEAR PrnStr
mov si,PCaddr
call NEAR PrnStr
mov ax,bp
xchg ah,al
call NEAR PrnHex
xchg ah,al
call NEAR PrnHex
; display the 4 opcodes at the PC location
mov si,OpcMs0
call NEAR PrnStr
mov al,[es:Z80+bp+0]
call NEAR PrnHex
mov si,SpcMsg
call NEAR PrnStr
mov al,[es:Z80+bp+1]
call NEAR PrnHex
mov si,SpcMsg
call NEAR PrnStr
mov al,[es:Z80+bp+2]
call NEAR PrnHex
mov si,SpcMsg
call NEAR PrnStr
mov al,[es:Z80+bp+3]
call NEAR PrnHex
mov si,OpcMs1
call NEAR PrnStr
ActRE: mov si,REsels
call NEAR PrnStr
mov si,KeyRE
call NEAR GetAct
call NEAR ClsWnd
cmp al,'R'
jz z80rs0
jmp NEAR Z80ext
z80rs0: jmp NEAR Z80res
BtfMsg: db 'Failure loading Z80 system code$'
SysMsg: db 'Disk in drive is not a Z80 system disk', 0dh, 0ah
db 'Requires C3 hex (Z80 Jump) as 1st byte$'
OpcMsg: db 'Undocumented Z80 opcode$'
FncMsg: db 'OUT (Fn),A Function Not Supported$'
IntMsg: db 'Illegal OUT (Fn),A / 8086 INT function call$'
CdeMsg: db 'No code emulation for this Z80 opcode', 0dh, 0ah
db 'Mnemonic: $'
PCaddr: db 0dh, 0ah
db ' at PC: $'
OpcMs0: db ' ($'
OpcMs1: db ')$'
SpcMsg: db ' $'
REsels: db 0dh, 0ah, 0ah
db '[R]eset Z80 [E]xit to DOS', 0dh, 0ah
db 'Select ?: $'
KeyRE: db 'RE$'
;===============================================================================
; User Interrupt (CTRL+ALT+I)
;===============================================================================
ReqAct: pushf
push ax
push bx
push cx
push dx
push es
push ds
pop es
mov si,Tx
mov di,T0
mov cx,512
cld
rep movsb
pop es
dec bp ;point to Z80 current PC
mov dh,9 ;window Y start
mov dl,19 ;window X start
mov ch,15 ;window Y finish
mov cl,60 ;window X finish
call NEAR OpnWnd
mov si,ExeMsg
call NEAR PrnStr
mov ax,bp
xchg ah,al
call NEAR PrnHex
xchg ah,al
call NEAR PrnHex
mov si,RECmsg
call NEAR PrnStr
mov si,KeyREC
call NEAR GetAct
call NEAR ClsWnd
cmp al,'R'
jz z80rs1
cmp al,'C'
jz conact
pop dx
pop cx
pop bx
pop ax
popf
jmp NEAR Z80ext
z80rs1: pop dx
pop cx
pop bx
pop ax
popf
jmp NEAR Z80res
conact: pop dx
pop cx
pop bx
pop ax
popf
jmp NEAR Z80opc
ExeMsg: db 'Execution Interrupted (Ctrl + Alt + I)', 0dh, 0ah
db 'Current PC: $'
RECmsg: db 0dh, 0ah, 0ah
db '[R]eset Z80 [E]xit to DOS [C]ontinue', 0dh, 0ah
db 'Select ?: $'
KeyREC: db 'REC$'
;===============================================================================
; Various other functions
;===============================================================================
prmsta: mov al,[prmflg]
retn
prmget: mov word [es:Z80+bx],ds
mov ax,prmbuf
mov word [es:Z80+bx+2],ax
retn
vidsta: mov al,[vidoff]
retn
vidset: mov [vidoff],al
retn
;
usrdta times 32 db 0
usrbyt: cmp bx,020h ;is user byte in range
jnc usrext
or cl,cl
jz usrget
mov BYTE [usrdta+bx],al ;set user byte
retn
usrget: mov al,[usrdta+bx] ;get user byte
usrext: retn
;
BootDr db 0
GtBoot: mov al,[BootDr]
retn
;
;===============================================================================
; Block memory routines:
;
; blkcnt:- Get count of blocks available (1 block=16384 bytes)
; Return: A(AL)=number of blocks
; 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
; 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
; 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
;===============================================================================
; Get count of blocks available (1 block=16384 bytes)
BufCnt db 0
blkcnt: mov al,[BufCnt]
retn
; Get 128 bytes from block (1 record=128 bytes) from the current DMA bank.
blkget: mov di,bx ;destination address in Z80 reg HL
call blkprm
jz blkg
retn
blkg: mov si,cx
cld ;move upwards
nxtget: mov BYTE [reqcpy],0ffh ;copy common required
mov cx,128
mov [sveamt],cx
mov [sveoff],di
push ds
push es
mov es,[Z80dma] ;bank #0, #1 DMA segment address
mov [sveseg],es
mov ds,[BufSeg+bx]
rep movsb
pop es
pop ds
call NEAR cpycom ;copy common if needed
dec dl
jnz nxtget
xor al,al
retn
; Put 128 bytes in block (1 record=128 bytes) for the current DMA bank.
blkput: mov si,bx ;source address in Z80 reg HL
call blkprm
jz blkp
retn
blkp: mov di,cx
push ds
push es
mov es,[BufSeg+bx]
mov ds,[Z80dma] ;bank #0, #1 DMA segment address
cld ;move upwards
nxtput: mov cx,128
rep movsb
dec dl
jnz nxtput
pop es
pop ds
xor al,al
retn
; Fill 128 bytes in block (1 record=128 bytes) for the current DMA bank.
blkfil: mov si,ax
call blkprm
jz blkf
retn
blkf: mov ax,si
mov di,cx
cld ;fill upwards
push es
mov es,[BufSeg+bx]
nxtfil: mov cx,128
rep stosb
dec dl
jnz nxtfil
pop es
xor al,al
retn
blkprm: cmp cl,[BufCnt] ;block # in Z80 reg C
jnc blkerr
cmp dh,128
jnc blkerr
xor bh,bh
mov bl,cl
shl bl,1
mov ch,dh
xor cl,cl
shr cx,1
xor al,al
retn
blkerr: xor al,al
inc al
retn
;===============================================================================
; Interrupt services:
;
; GtZseg:- Return Z80 map segment address
; Pass: HL(BX)=Z80 address to place result
; 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
; GetByt:- Get byte from memory
; Pass: DE(DX)=segment
; HL(BX)=offset
; Return: A(AL)=byte
; SetByt:- Set byte in memory
; Pass: DE(DX)=segment
; HL(BX)=offset
; A(AL)=byte
;===============================================================================
; Call a ROM BIOS/DOS Interrupt service
intfnc: cmp cx,0aa55h ;safety gaurd check
jz Pass1
jmp IntErr
Pass1: cmp dx,055aah ;safety gaurd check
jz Pass2
jmp IntErr
Pass2: mov byte [cs:setint+1],al
mov bp,bx ;base address of register table
mov [SaveBP],bp
push word [es:Z80+bp+000h] ;AX
push word [es:Z80+bp+002h] ;BX
push word [es:Z80+bp+004h] ;CX
push word [es:Z80+bp+006h] ;DX
push word [es:Z80+bp+008h] ;BP
push word [es:Z80+bp+00ah] ;SI
push word [es:Z80+bp+00ch] ;DI
push word [es:Z80+bp+00eh] ;DS
push word [es:Z80+bp+010h] ;ES
pop es
pop ds
pop di
pop si
pop bp
pop dx
pop cx
pop bx
pop ax
setint: int 0 ;interrupt placed here
push es
push ds
push di
push si
push bp
push dx
push cx
push bx
push ax
mov ax,cs
mov ds,ax
mov ax,[Z80seg]
mov es,ax
mov bp,[SaveBP]
pop word [es:Z80+bp+000h] ;AX
pop word [es:Z80+bp+002h] ;BX
pop word [es:Z80+bp+004h] ;CX
pop word [es:Z80+bp+006h] ;DX
pop word [es:Z80+bp+008h] ;BP
pop word [es:Z80+bp+00ah] ;SI
pop word [es:Z80+bp+00ch] ;DI
pop word [es:Z80+bp+00eh] ;DS
pop word [es:Z80+bp+010h] ;ES
pushf
pop word [es:Z80+bp+012h] ;FLAGS
retn
SaveBP resw 1
; Return Z80 map segment address
GtZseg: mov word [es:Z80+bx],es ;bank #0 or Bank #1 segment
retn
; Get byte from memory
GetByt: push ds
mov ds,dx
mov al,[bx]
pop ds
retn
; Set byte in memory
SetByt: push ds
mov ds,dx
mov [bx],al
pop ds
retn
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,178 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Instruction Handler for Extended Opcodes *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 28 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_8086, CBxops, CByops, IXops, IYops, EDops, CBops
GLOBAL FlagX, FlagN, FlagNx, IFF
GLOBAL Z80I, Z80R, Z80SP, Z80IX, Z80IY, Z80AF, Z80BC, Z80DE, Z80HL
; declared in TABLE.ASM
EXTERN T0, T1, T2, T3
EXTERN T4, T5, T6, T7
%include "macros.asm"
svewrd resw 1 ;temporary word storage
FlagX resb 1 ;saves flag bits 5 and 3
FlagN resb 1 ;Emulates the Z80 N flag (bit 1)
FlagNx resb 1 ;
IFF resb 1 ;Z80 Interrupt Flip Flop
Z80I resb 1 ;Z80 interrupt register
Z80R resb 1 ;Z80 refresh register
Z80SP resw 1 ;Z80 stack pointer storage
Z80IX resw 1 ;Z80 IX index register storage
Z80IY resw 1 ;Z80 IY index register storage
Z80AF resw 1 ;Z80 2nd AF register storage
Z80BC resw 1 ;Z80 2nd BC register storage
Z80DE resw 1 ;Z80 2nd DE register storage
Z80HL resw 1 ;Z80 2nd HL register storage
; High level interface functions accessed with OUT (FncNmb),A
Z_8086: mov si,ax ;save Z80 reg A
xor ah,ah
mov al,[es:Z80+bp] ;8086 code function number
mov di,ax
shl di,1 ;offset into function table
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A
push cx ;save Z80 reg BC
push dx ;save Z80 reg DE
push bx ;save Z80 reg HL
push bp ;save Z80 reg PC
call WORD [T7+di] ;call 8086 code function
pop bp ;restore Z80 reg PC
pop bx ;restore Z80 reg HL
pop dx ;restore Z80 reg DE
pop cx ;restore Z80 reg BC
or al,al ;set/res Z80 zero flag
XinstA
; $CB IX opcode of Z80 instruction
CBxops: lahf ;get Z80 reg F
mov si,ax ;save Z80 regs A and F
mov al,[es:Z80+bp] ;get IX offset
inc bp
cbw
add ax,[Z80IX]
mov [svewrd],ax ;save IX + signed offset
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
inc bp ;next Z80 PC
mov di,ax
shl di,1
mov ax,si ;restore Z80 reg A and F
sahf ;set Z80 reg F
mov si,[svewrd]
jmp WORD [T6+di]
; $CB IY opcode of Z80 instruction
CByops: lahf ;get Z80 reg F
mov si,ax ;save Z80 regs A and F
mov al,[es:Z80+bp] ;get IY offset
inc bp
cbw
add ax,[Z80IY]
mov [svewrd],ax ;save IY + signed offset
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
inc bp ;next Z80 PC
mov di,ax
shl di,1
mov ax,si ;restore Z80 reg A and F
sahf ;set Z80 reg F
mov si,[svewrd]
jmp WORD [T5+di]
; IX opcode of Z80 instruction
IXops: lahf ;get Z80 reg F
mov si,ax ;save Z80 regs A and F
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
mov di,ax
shl di,1
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A and F
sahf ;set Z80 reg F
jmp WORD [T4+di]
; IY opcode of Z80 instruction
IYops: lahf ;get Z80 reg F
mov si,ax ;save Z80 regs A and F
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
mov di,ax
shl di,1
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A and F
sahf ;set Z80 reg F
jmp WORD [T3+di]
; $ED opcode of Z80 instruction
EDops: lahf ;get Z80 reg F
mov si,ax ;save Z80 regs A and F
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
mov di,ax
shl di,1
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A and F
sahf ;set Z80 reg F
jmp WORD [T2+di]
; $CB opcode of Z80 instruction
CBops: lahf ;get Z80 reg F
mov si,ax ;save Z80 regs A and F
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
mov di,ax
shl di,1
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A and F
sahf ;set Z80 reg F
jmp WORD [T1+di]
end

View File

@@ -0,0 +1,281 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Input and Output Group *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed 'lea' instructions to 'mov'.
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT .code public align=16
GLOBAL Z_INan
GLOBAL Z_INbc, Z_INcc, Z_INdc, Z_INec
GLOBAL Z_INhc, Z_INlc, Z_INfc, Z_INac
GLOBAL Z_OUTcb, Z_OUTcc, Z_OUTcd, Z_OUTce
GLOBAL Z_OUTch, Z_OUTcl, Z_OUTca
GLOBAL Z_INI, Z_INIR, Z_IND, Z_INDR
GLOBAL Z_OUTI, Z_OTIR, Z_OUTD, Z_OTDR
; declared in FUNCTION.ASM
EXTERN Nocde0, Nocde1
%include "macros.asm"
;***********************************************************
;* IN B,(C) Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x P 0 . *
;***********************************************************
Z_INbc:
mov si,inbc
jmp NEAR Nocde0
inbc: db 'IN B,(C)$'
;***********************************************************
;* IN C,(C) Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x P 0 . *
;***********************************************************
Z_INcc:
mov si,incc_
jmp NEAR Nocde0
incc_: db 'IN C,(C)$'
;***********************************************************
;* IN D,(C) Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x P 0 . *
;***********************************************************
Z_INdc:
mov si,indc
jmp NEAR Nocde0
indc: db 'IN D,(C)$'
;***********************************************************
;* IN E,(C) Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x P 0 . *
;***********************************************************
Z_INec:
mov si,inec
jmp NEAR Nocde0
inec: db 'IN E,(C)$'
;***********************************************************
;* IN H,(C) Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x P 0 . *
;***********************************************************
Z_INhc:
mov si,inhc
jmp NEAR Nocde0
inhc: db 'IN H,(C)$'
;***********************************************************
;* IN L,(C) Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x P 0 . *
;***********************************************************
Z_INlc:
mov si,inlc
jmp NEAR Nocde0
inlc: db 'IN L,(C)$'
;***********************************************************
;* IN A,(C) Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x P 0 . *
;***********************************************************
Z_INac:
mov si,inac
jmp NEAR Nocde0
inac: db 'IN A,(C)$'
;***********************************************************
;* IN (HL),(C) Flags: S Z - H - P/V N C *
;* ? ? x ? x ? ? ? *
;***********************************************************
Z_INfc:
mov si,infc
jmp NEAR Nocde0
infc: db 'IN (HL),(C)$'
;***********************************************************
;* IN A,(NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_INan:
mov si,inan
jmp NEAR Nocde1
inan: db 'IN A,(NN)$'
;***********************************************************
;* INI Flags: S Z - H - P/V N C *
;* x ^ x x x x 1 x *
;***********************************************************
Z_INI:
mov si,ini
jmp NEAR Nocde0
ini: db 'INI$'
;***********************************************************
;* IND Flags: S Z - H - P/V N C *
;* x ^ x x x x 1 x *
;***********************************************************
Z_IND:
mov si,ind
jmp NEAR Nocde0
ind: db 'IND$'
;***********************************************************
;* INIR Flags: S Z - H - P/V N C *
;* x 1 x x x x 1 x *
;***********************************************************
Z_INIR:
mov si,inir
jmp NEAR Nocde0
inir: db 'INIR$'
;***********************************************************
;* INDR Flags: S Z - H - P/V N C *
;* x 1 x x x x 1 x *
;***********************************************************
Z_INDR:
mov si,indr
jmp NEAR Nocde0
indr: db 'INDR$'
;***********************************************************
;* OUT (C),B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_OUTcb:
mov si,outcb
jmp NEAR Nocde0
outcb: db 'OUT (C),B$'
;***********************************************************
;* OUT (C),C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_OUTcc:
mov si,outcc
jmp NEAR Nocde0
outcc: db 'OUT (C),C$'
;***********************************************************
;* OUT (C),D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_OUTcd:
mov si,outcd
jmp NEAR Nocde0
outcd: db 'OUT (C),D$'
;***********************************************************
;* OUT (C),E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_OUTce:
mov si,outce
jmp NEAR Nocde0
outce: db 'OUT (C),E$'
;***********************************************************
;* OUT (C),H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_OUTch:
mov si,outch
jmp NEAR Nocde0
outch: db 'OUT (C),H$'
;***********************************************************
;* OUT (C),L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_OUTcl:
mov si,outcl
jmp NEAR Nocde0
outcl: db 'OUT (C),L$'
;***********************************************************
;* OUT (C),A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_OUTca:
mov si,outca
jmp NEAR Nocde0
outca: db 'OUT (C),A$'
;***********************************************************
;* OUT (NN),A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
; used for 8086 interfacing
;***********************************************************
;* OUTI Flags: S Z - H - P/V N C *
;* x ^ x x x x 1 x *
;***********************************************************
Z_OUTI:
mov si,outi
jmp NEAR Nocde0
outi: db 'OUTI$'
;***********************************************************
;* OUTD Flags: S Z - H - P/V N C *
;* x ^ x x x x 1 x *
;***********************************************************
Z_OUTD:
mov si,outd
jmp NEAR Nocde0
outd: db 'OUTD$'
;***********************************************************
;* OTIR Flags: S Z - H - P/V N C *
;* x 1 x x x x 1 x *
;***********************************************************
Z_OTIR:
mov si,otir
jmp NEAR Nocde0
otir: db 'OTIR$'
;***********************************************************
;* OTDR Flags: S Z - H - P/V N C *
;* x 1 x x x x 1 x *
;***********************************************************
Z_OTDR:
mov si,otdr
jmp NEAR Nocde0
otdr: db 'OTDR$'
end

View File

@@ -0,0 +1,268 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Jump Group *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 28 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_JPx, Z_JPy, Z_JPhl
GLOBAL Z_JP, Z_JPNZ, Z_JPZ, Z_JPNC, Z_JPC, Z_JPPO
GLOBAL Z_JPPE, Z_JPP, Z_JPM
GLOBAL Z_JR, Z_JRNZ, Z_JRZ, Z_JRNC, Z_JRC
GLOBAL Z_DJNZ
; declared in INSTHAND.ASM
EXTERN Z80IX, Z80IY
%include "macros.asm"
;***********************************************************
;* JP NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JP:
mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP NZ,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPNZ:
jnz jumpnz
lahf
inc bp
inc bp
XinstB
jumpnz: mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP Z,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPZ:
jz jumpz
lahf
inc bp
inc bp
XinstB
jumpz: mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP NC,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPNC:
jnc jumpnc
lahf
inc bp
inc bp
XinstB
jumpnc: mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP C,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPC:
jc jumpc
lahf
inc bp
inc bp
XinstB
jumpc: mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP PO,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPPO:
jpo jumppo
lahf
inc bp
inc bp
XinstB
jumppo: mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP PE,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPPE:
jpe jumppe
lahf
inc bp
inc bp
XinstB
jumppe: mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP P,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPP:
jns jumpp
lahf
inc bp
inc bp
XinstB
jumpp: mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP M,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPM:
js jumpm
lahf
inc bp
inc bp
XinstB
jumpm: mov bp,word [es:Z80+bp]
XinstA
;***********************************************************
;* JP (HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPhl:
mov bp,bx
XinstA
;***********************************************************
;* JP (IX) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPx:
mov bp,[Z80IX]
XinstA
;***********************************************************
;* JP (IY) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JPy:
mov bp,[Z80IY]
XinstA
;***********************************************************
;* JR RR Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JR:
lahf
JRx: mov si,ax
mov al,[es:Z80+bp]
inc bp ;points to next instruction
cbw ;label: jr label = FE hex (-2)
add bp,ax
mov ax,si
XinstB
;***********************************************************
;* JR C,RR Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JRC:
jc jrc
lahf
inc bp
XinstB
jrc: jmp Z_JR
;***********************************************************
;* JR NC,RR Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JRNC:
jnc jrnc
lahf
inc bp
XinstB
jrnc: jmp Z_JR
;***********************************************************
;* JR Z,RR Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JRZ:
jz jrz
lahf
inc bp
XinstB
jrz: jmp Z_JR
;***********************************************************
;* JR NZ,RR Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_JRNZ:
jnz jrnz
lahf
inc bp
XinstB
jrnz: jmp Z_JR
;***********************************************************
;* DJNZ RR Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_DJNZ:
lahf
dec ch
jnz djnz
inc bp
XinstB
djnz: jmp JRx
end

View File

@@ -0,0 +1,480 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* 16-bit Load Group *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 28 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_LDxn, Z_LDmx, Z_LDxm, Z_POPx, Z_PUSHx, Z_LDspx
GLOBAL Z_LDyn, Z_LDmy, Z_LDym, Z_POPy, Z_PUSHy, Z_LDspy
GLOBAL Z_LDmbc, Z_LDbcm, Z_LDmde, Z_LDdem, Z_LDmsp, Z_LDspm
GLOBAL Z_LDbcn, Z_LDden, Z_LDhln, Z_LDmhl, Z_LDhlm, Z_LDspn
GLOBAL Z_POPbc, Z_PUSHbc, Z_POPde, Z_PUSHde, Z_POPhl, Z_PUSHhl
GLOBAL Z_POPaf, Z_PUSHaf
GLOBAL Z_LDsphl
; declared in INSTHAND.ASM
EXTERN Z80SP, Z80IX, Z80IY
EXTERN FlagN, FlagX
%include "macros.asm"
;***********************************************************
;* LD BC,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDbcn:
mov cx,word [es:Z80+bp]
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD DE,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDden:
mov dx,word [es:Z80+bp]
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD HL,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDhln:
mov bx,word [es:Z80+bp]
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD SP,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDspn:
mov di,word [es:Z80+bp]
mov [Z80SP],di
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD IX,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDxn:
mov di,word [es:Z80+bp]
mov [Z80IX],di
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD IY,NNNN Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDyn:
mov di,word [es:Z80+bp]
mov [Z80IY],di
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD BC,(NNNN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDbcm:
mov di,word [es:Z80+bp]
mov cx,word [es:Z80+di]
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD DE,(NNNN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDdem:
mov di,word [es:Z80+bp]
mov dx,word [es:Z80+di]
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD HL,(NNNN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDhlm:
mov di,word [es:Z80+bp]
mov bx,word [es:Z80+di]
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD SP,(NNNN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDspm:
mov di,word [es:Z80+bp]
mov si,word [es:Z80+di]
mov [Z80SP],si
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD IX,(NNNN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDxm:
mov di,word [es:Z80+bp]
mov si,word [es:Z80+di]
mov [Z80IX],si
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD IY,(NNNN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDym:
mov di,word [es:Z80+bp]
mov si,word [es:Z80+di]
mov [Z80IY],si
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD (NNNN),BC Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDmbc:
mov di,word [es:Z80+bp]
mov word [es:Z80+di],cx
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD (NNNN),DE Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDmde:
mov di,word [es:Z80+bp]
mov word [es:Z80+di],dx
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD (NNNN),HL Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDmhl:
mov di,word [es:Z80+bp]
mov word [es:Z80+di],bx
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD (NNNN),SP Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDmsp:
mov si,[Z80SP]
mov di,word [es:Z80+bp]
mov word [es:Z80+di],si
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD (NNNN),IX Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDmx:
mov si,[Z80IX]
mov di,word [es:Z80+bp]
mov word [es:Z80+di],si
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD (NNNN),IY Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDmy:
mov si,[Z80IY]
mov di,word [es:Z80+bp]
mov word [es:Z80+di],si
lahf
inc bp
inc bp
XinstB
;***********************************************************
;* LD SP,HL Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDsphl:
mov [Z80SP],bx
XinstA
;***********************************************************
;* LD SP,IX Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDspx:
mov di,[Z80IX]
mov [Z80SP],di
XinstA
;***********************************************************
;* LD SP,IY Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_LDspy:
mov di,[Z80IY]
mov [Z80SP],di
XinstA
;***********************************************************
;* PUSH AF Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_PUSHaf:
pushf
lahf
and ah,11010101b ;reset unused 8086 flags
or ah,[FlagN] ;add in Z80 negative flag
or ah,[FlagX] ;add in Z80 unused flags
mov di,[Z80SP]
dec di
mov BYTE [es:Z80+di],al ;Z80 reg A on stack 1st
dec di
mov BYTE [es:Z80+di],ah ;Z80 flag register last
mov [Z80SP],di
popf
XinstA
;***********************************************************
;* PUSH BC Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_PUSHbc:
lahf
mov di,[Z80SP]
dec di
dec di
mov word [es:Z80+di],cx
mov [Z80SP],di
XinstB
;***********************************************************
;* PUSH DE Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_PUSHde:
lahf
mov di,[Z80SP]
dec di
dec di
mov word [es:Z80+di],dx
mov [Z80SP],di
XinstB
;***********************************************************
;* PUSH HL Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_PUSHhl:
lahf
mov di,[Z80SP]
dec di
dec di
mov word [es:Z80+di],bx
mov [Z80SP],di
XinstB
;***********************************************************
;* PUSH IX Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_PUSHx:
lahf
mov di,[Z80SP]
dec di
dec di
mov [Z80SP],di
mov si,[Z80IX]
mov word [es:Z80+di],si
XinstB
;***********************************************************
;* PUSH IY Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_PUSHy:
lahf
mov di,[Z80SP]
dec di
dec di
mov [Z80SP],di
mov si,[Z80IY]
mov word [es:Z80+di],si
XinstB
;***********************************************************
;* POP AF Flags: S Z - H - P/V N C *
;* ^ ^ x ^ x ^ ^ ^ *
;***********************************************************
Z_POPaf:
mov di,[Z80SP]
mov ah,[es:Z80+di]
inc di
mov al,[es:Z80+di]
inc di
mov [Z80SP],di
mov [FlagN],ah
and BYTE [FlagN],00000010b
mov [FlagX],ah
and BYTE [FlagX],00101000b
and ah,11010101b
XinstB
;***********************************************************
;* POP BC Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_POPbc:
lahf
mov di,[Z80SP]
mov cx,word [es:Z80+di]
inc di
inc di
mov [Z80SP],di
XinstB
;***********************************************************
;* POP DE Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_POPde:
lahf
mov di,[Z80SP]
mov dx,word [es:Z80+di]
inc di
inc di
mov [Z80SP],di
XinstB
;***********************************************************
;* POP HL Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_POPhl:
lahf
mov di,[Z80SP]
mov bx,word [es:Z80+di]
inc di
inc di
mov [Z80SP],di
XinstB
;***********************************************************
;* POP IX Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_POPx:
lahf
mov di,[Z80SP]
mov si,word [es:Z80+di]
mov [Z80IX],si
inc di
inc di
mov [Z80SP],di
XinstB
;***********************************************************
;* POP IY Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_POPy:
lahf
mov di,[Z80SP]
mov si,word [es:Z80+di]
mov [Z80IY],si
inc di
inc di
mov [Z80SP],di
XinstB
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,99 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Macros *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Added 'BITS 16' and 'CPU 8086' and make all ASM files include this file.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
;
; v1.00 - 5 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
BITS 16
CPU 8086
EXTERN T0
%MACRO XinstA 0
lahf ;get Z80 reg F into reg ah
mov si,ax ;save Z80 regs A and F
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
mov di,ax
shl di,1 ;T0 instruction table offset
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A and F
sahf ;set 8086 Flags with Z80 reg F (ah)
jmp WORD [T0+di]
%ENDMACRO
%MACRO XinstB 0
mov si,ax ;save Z80 regs A and F
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
mov di,ax
shl di,1 ;T0 instruction table offset
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A and F
sahf ;set 8086 Flags with Z80 reg F (ah)
jmp WORD [T0+di]
%ENDMACRO
%MACRO XinstC 0
lahf ;get Z80 reg F into reg ah
and ah,11111011b ;reset P/V to indicate no overflow
mov si,ax ;save Z80 regs A and F
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
mov di,ax
shl di,1 ;T0 instruction table offset
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A and F
sahf ;set 8086 Flags with Z80 reg F (ah)
jmp WORD [T0+di]
%ENDMACRO
%MACRO XinstD 0
lahf ;get Z80 reg F into reg ah
or ah,00000100b ;set P/V to indicate overflow
mov si,ax ;save Z80 regs A and F
xor ah,ah
mov al,[es:Z80+bp] ;get Z80 opcode
mov di,ax
shl di,1 ;T0 instruction table offset
inc bp ;next Z80 PC
mov ax,si ;restore Z80 reg A and F
sahf ;set 8086 Flags with Z80 reg F (ah)
jmp WORD [T0+di]
%ENDMACRO

View File

@@ -0,0 +1,411 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Main assembly module *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 20 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Removed one occurence of label NEAR from: 'lea dx,[NEAR criter]'
; - Changed 'lea' instructions to 'mov'.
; - Removed 'seg' from 'mov ax,seg stkseg' and 'mov bx,seg Zend'
; - Removed 'ss:' from 'mov bx,ss:topstk'
; - Added '..start:' before the 'Z80emu:' label.
; - Changed all uses of Z80 map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
; - Changed 'SgnMsg' version to use APPVER passed from Makefile.
; - Changed command line drive options from A: and B: to now use -A and -B
; and also allow Z80 system parameters to be flagged even if floppy
; options are specified.
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z80res, Z80ext, Z80opc
GLOBAL BufSeg, VidSeg, VidBuf
GLOBAL prmbuf, prmflg, vidoff
; declared in WINDOW.ASM
EXTERN OpnWnd, ClsWnd
EXTERN PrnStr, GetKey, EraScr, HdeCur
; declared in HARDWARE.ASM
EXTERN bnkini, bnkres
EXTERN newkbd, oldkbd
EXTERN rdflop, rdhard
EXTERN HrdFle, Handle
; declared in FUNCTION.ASM
EXTERN criter, fboot, SysErr
EXTERN BufCnt, BootDr
; declared in INSTHAND.ASM
EXTERN FlagX, FlagN, FlagNx, IFF
EXTERN Z80I, Z80R, Z80SP, Z80IX, Z80IY
EXTERN Z80AF, Z80BC, Z80DE, Z80HL
%include "macros.asm"
BLKMAX equ 64 ;maximum number of 16 K-byte memory blocks
prmbuf resb 80 ;buffer for command tail parameters
BufSeg resw BLKMAX ;table of segments for 16 K-byte blocks
VidSeg resw 1
VidBuf resw 1
VidMde resb 1
vidoff db 0 ;disable output to video drivers flag
prmflg db 0 ;command tail passed flag
flpdrv db 0 ;floppy to boot up from, 0=A or 1=B
flpflg db 0 ;boot from floppy flag
CtrlC resb 1 ;saved state of Ctrl-C flag
; Z80 Emulator execution begins here
..start:
Z80emu:
mov ax,stkseg
mov bx,topstk
cli
mov ss,ax ;set stack segment register
mov sp,bx ;set stack pointer register
sti
mov ax,cs
mov ds,ax ;set data segment=code segment
; Save command tail in Program Segment Prifix (PSP)
push ds
push es
mov si,0080h ;source offset
mov di,prmbuf ;destination offset buffer
mov cx,80 ;amount to move
mov ax,es
mov ds,ax ;set source segment (PSP)
mov ax,cs
mov es,ax ;set destination segment
cld ;move forward
rep movsb
pop es
pop ds
; Check command tail in Program Segment Prifix (PSP)
mov si,0080h
mov cl,[es:si] ;size of command tail (ES=PSP)
mov di,si ;copy of command tail offset
xor ch,ch
add di,cx ;point to last character
chkspc: cmp byte [es:di],' ' ;trailing space character ?
jnz chkprm
dec cl
jz setvid
dec di ;work backwards
jmp chkspc
chkprm: or cl,cl
jz setvid ;no tail remaining if count is 0
dec cl
inc si
mov al,[es:si] ;get character from command tail
cmp al,' ' ;ignore leading space characters
jz chkprm
cmp al,'-' ;leading hyphen character ?
jnz chkdir ;no, then check for redirection
or cl,cl
jz setvid ;error in option if end of tail
inc si
mov al,[es:si]
and al,11011111b ;convert to uppercase
cmp al,'A' ;force boot from A: ?
jz flpopt
cmp al,'B' ;force boot from B: ?
jnz setvid ;error in floppy selection
flpopt: mov [DrvChr],al ;insert letter into message
sub al,'A'
mov [flpdrv],al ;drive code of floppy to be booted
mov BYTE [flpflg],0ffh ;boot from floppy flag
dec cl ;any more tail left ?
jz setvid
inc si
chkdir: cmp BYTE [es:si],'<' ;DOS input redirection ?
jz setvid
cmp BYTE [es:si],'>' ;DOS output redirection ?
jz setvid
mov BYTE [prmflg],0ffh ;set command tail flag true
mov BYTE [vidoff],0ffh ;disable video output
; Determine and set video display mode
setvid: mov ah,00fh ;get current video mode function
int 010h
mov [VidMde],al ;save video mode
int 011h ;get equipment list interrupt
and al,00110000b ;keep initial video mode bits
mov ah,007h ;monochrome 25 * 80 text display
mov WORD [VidSeg],0b000h ;monochrome video segment
or al,al ;unused video system ?
jz MonVid
cmp al,00110000b ;monochrome video system ?
jz MonVid
mov ah,002h ;colour 25 * 80 text display
mov WORD [VidSeg],0b800h ;colour video segment
MonVid: cmp BYTE [prmflg],0 ;do not set video if command tail
jnz seterr
mov al,ah
mov ah,000h ;set video mode function
int 010h
; Setup local DOS critical error handler
seterr: mov ah,025h ;set interrupt function
mov al,024h ;critical error handler vector
mov dx,criter
int 21h ;change vector via DOS
; Setup keyboard intercept and Ctrl C flag
mov ah,033h ;get/set Ctrl-C flag function
mov al,000h ;get function
int 021h
mov [CtrlC],al ;save flag for later
mov ah,033h ;get/set Ctrl-C flag function
mov al,001h ;set function
xor dl,dl ;turn of Ctrl-C action
int 021h
call NEAR newkbd
; Resize memory for Z80 Emulator program
mov ax,es ;get PSP address in ES
mov bx,Zend
sub bx,ax ;program size in BX
mov ah,04ah ;modify allocated memory function
push ds
int 021h
pop ds
jnc Z80mp0
jmp ErrAlo
; Allocate memory for Z80 address map (2 maps of 64k)
Z80mp0: mov ah,048h ;allocate memory function
mov bx,4096 ;64K-bytes for Z80 bank 0
int 021h
mov cx,ax ;save bank #0 segment address
jnc Z80mp1
jmp ErrAlo
Z80mp1: mov ah,048h ;allocate memory function
mov bx,4096 ;64K-bytes for Z80 bank 1
int 021h
call NEAR bnkini ;initialize variables
jnc AloWnd
jmp ErrAlo
; Allocate memory for window useage
AloWnd: mov ah,048h ;allocate memory function
mov bx,1024 ;allocate 16 K-bytes
int 021h
jnc VidSet
jmp ErrAlo
VidSet: mov [VidBuf],ax ;save segment of 16 K-byte block
; Allocate remaining memory in 16 K-byte blocks
mov BYTE [BufCnt],0 ;set block counter to 0
xor bx,bx ;set table offset to 0
nxtalo: push bx
mov ah,048h ;allocate memory function
mov bx,1024 ;allocate 16 K-bytes at a time
push ds
push es
int 021h
pop es
pop ds
pop bx
jc OpnHrd
mov WORD [BufSeg+bx],ax ;save segment of 16 K-byte block
inc BYTE [BufCnt] ;count 16 K-byte blocks
inc bx
inc bx
cmp BYTE [BufCnt],BLKMAX ;allocate upto 64 blocks of memory
jnz nxtalo
; Open Z80 hard disk file image on current drive
OpnHrd: mov ah,019h ;get current disk function
int 021h ;A=0, B=1, C=2, etc
cmp al,02h
jc Z80res ;HDD file not supported on floppy
mov dx,Fname ;offset address of ASCIIZ string
mov ah,043h ;get/set file attributes function
mov al,001h ;set attribute function
mov cx,0 ;read/write file attribute
int 021h ;change attribute
mov dx,Fname ;offset address of ASCIIZ string
mov ah,03dh ;open file function
mov al,002h ;access mode, 2=read/write
int 021h ;open disk file
jc Z80res ;HDD file not found if carry
mov [Handle],ax ;save file handle
mov ah,019h ;get current disk function
int 021h
mov [HrdFle],al ;save drive code
; Z80 reset point, check what drive to boot from
Z80res: call NEAR bnkres ;reset bank #0, #1
call NEAR EraScr ;clear the screen
cmp BYTE [flpflg],0 ;force boot up from floppy ?
jnz LdBoot
cmp BYTE [HrdFle],0ffh ;HDD file present ?
jz Prompt
mov BYTE [es:Z80+0080h],0 ;kill any existing $C3 jump code
mov dl,[HrdFle] ;HDD file drive
mov [BootDr],dl ;save boot drive
xor ch,ch ;track #0
mov cl,1 ;sector #1
mov bx,0080h ;BX=buffer
call NEAR rdhard ;read 1st sector from HDD file
jmp chkcde
; Prompt the user for a Z80 system disk in drive A
Prompt: mov dh,9
mov dl,18
mov ch,15
mov cl,62
call NEAR OpnWnd
mov si,SgnMsg
call NEAR PrnStr
call NEAR HdeCur ;hide the cursor
mov si,SgnKey ;keys ESC, ^C, ENTER
call NEAR GetKey
call NEAR ClsWnd
cmp al,27 ;ESC key pressed ?
jz Z80abt
cmp al,3 ;Ctrl-C key pressed ?
jz Z80abt ;fall through if ENTER key
; Load 1st sector from Z80 system disk in drive A
LdBoot: mov BYTE [es:Z80+0080h],0 ;kill any existing $C3 jump code
mov dh,0 ;side #0
mov dl,[flpdrv] ;drive code
mov [BootDr],dl ;save boot drive
mov ch,0 ;track #0
mov cl,1 ;sector #1
mov al,2 ;sector size code (2=512)
mov bx,0080h ;BX=buffer
call NEAR rdflop ;read 1st sector from floppy disk
chkcde: or al,al
jz loaded
jmp NEAR fboot ;failed to boot disk if here
loaded: cmp BYTE [es:Z80+0080h],0c3h ;Z80 jump in 1st byte of sector ?
jz Z80exe
jmp NEAR SysErr ;system not designed for Z80 Emulator
Z80abt: jmp Z80ext ;exit the Z80 Emulator program
; Reset Z80 registers and execute Z80 code
Z80exe: xor ax,ax ;Z80 reg A=0
mov cx,ax ;Z80 reg BC=0
mov dx,ax ;Z80 reg DE=0
mov bx,ax ;Z80 reg HL=0
mov [Z80IX],ax ;Z80 reg IX=0
mov [Z80IY],ax ;Z80 reg IY=0
mov [Z80AF],ax ;Z80 reg AF'=0
mov [Z80BC],ax ;Z80 reg BC'=0
mov [Z80DE],ax ;Z80 reg DE'=0
mov [Z80HL],ax ;Z80 reg HL'=0
mov [FlagX],ah ;Z80 unused flag bits = 0
mov [FlagN],ah ;Z80 N flag=0
mov [FlagNx],ah ;Z80 N' flag=0
mov [IFF],ah ;Z80 interrupt Flip Flop = 0 (DI)
sahf ;Z80 reg F=0
mov bp,0080h ;Z80 reg PC=0080 hex
mov WORD [Z80SP],0ffffh ;Z80 reg SP=FFFF hex
Z80opc: XinstA ;execute 1st Z80 instruction
; Insufficient memory for Z80 map / Window buffers
ErrAlo: mov dh,11
mov dl,20
mov ch,14
mov cl,59
call NEAR OpnWnd
mov si,MemMsg
call NEAR PrnStr
call NEAR HdeCur ;hide the cursor
mov si,MemKey
call NEAR GetKey ;wait for ESC key
call NEAR ClsWnd
; Exit the Z80 Emulator through here
Z80ext: cmp BYTE [HrdFle],0ffh ;Z80 hard disk file image opened ?
jz NotHDD
mov ah,03eh ;close file function
mov bx,[Handle]
int 021h ;flush and close file
mov dx,Fname ;offset address of ASCIIZ string
mov ah,043h ;get/set file attributes function
mov al,001h ;set attribute function
mov cx,001h ;read only file attribute
int 021h ;change attribute
NotHDD: call NEAR oldkbd
mov ah,033h ;get/set Ctrl-C flag function
mov al,001h ;set function
mov dl,[CtrlC] ;restore original Ctrl-C flag
int 021h
cmp BYTE [prmflg],0 ;was a command tail passed ?
jnz retcde
mov al,[VidMde] ;set original video mode
and al,01111111b ;force screen to be cleared
mov ah,000h ;set video mode function
int 010h
retcde: mov ax,4c00h ;return to DOS with code function
int 21h
SgnKey db 27, 3, 13, '$'
MemKey db 27, '$'
SgnMsg db ' Z80EM86-', APPVER, ' Z80 CPU Emulator', 0dh, 0ah
db ' Copyright (C) 1992-2009 Stewart Kay', 0dh, 0ah, 0ah
db ' Insert Z80 system disk into drive '
DrvChr db 'A:', 0dh, 0ah
db ' Press ENTER when ready$'
MemMsg db 'Insufficient memory for Z80 Emulator', 0dh, 0ah
db ' Press ESC to return to DOS$'
Fname db 'Z80HDD.DSK', 0
; Local stack area setup here
SEGMENT stkseg align=16
resw 256 ;reserve space for stack
topstk equ $
; Empty segment for finding program size
SEGMENT Zend align=16
end

View File

@@ -0,0 +1,736 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Bit Reset Group *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_RES0w, Z_RES1w, Z_RES2w, Z_RES3w, Z_RES4w, Z_RES5w, Z_RES6w, Z_RES7w
GLOBAL Z_RES0v, Z_RES1v, Z_RES2v, Z_RES3v, Z_RES4v, Z_RES5v, Z_RES6v, Z_RES7v
GLOBAL Z_RES0b, Z_RES0c, Z_RES0d, Z_RES0e, Z_RES0h, Z_RES0l, Z_RES0z, Z_RES0a
GLOBAL Z_RES1b, Z_RES1c, Z_RES1d, Z_RES1e, Z_RES1h, Z_RES1l, Z_RES1z, Z_RES1a
GLOBAL Z_RES2b, Z_RES2c, Z_RES2d, Z_RES2e, Z_RES2h, Z_RES2l, Z_RES2z, Z_RES2a
GLOBAL Z_RES3b, Z_RES3c, Z_RES3d, Z_RES3e, Z_RES3h, Z_RES3l, Z_RES3z, Z_RES3a
GLOBAL Z_RES4b, Z_RES4c, Z_RES4d, Z_RES4e, Z_RES4h, Z_RES4l, Z_RES4z, Z_RES4a
GLOBAL Z_RES5b, Z_RES5c, Z_RES5d, Z_RES5e, Z_RES5h, Z_RES5l, Z_RES5z, Z_RES5a
GLOBAL Z_RES6b, Z_RES6c, Z_RES6d, Z_RES6e, Z_RES6h, Z_RES6l, Z_RES6z, Z_RES6a
GLOBAL Z_RES7b, Z_RES7c, Z_RES7d, Z_RES7e, Z_RES7h, Z_RES7l, Z_RES7z, Z_RES7a
; declared in INSTHAND.ASM
EXTERN Z80IX, Z80IY
%include "macros.asm"
;***********************************************************
;* RES 0,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0b:
lahf
and ch,11111110b
XinstB
;***********************************************************
;* RES 1,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1b:
lahf
and ch,11111101b
XinstB
;***********************************************************
;* RES 2,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2b:
lahf
and ch,11111011b
XinstB
;***********************************************************
;* RES 3,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3b:
lahf
and ch,11110111b
XinstB
;***********************************************************
;* RES 4,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4b:
lahf
and ch,11101111b
XinstB
;***********************************************************
;* RES 5,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5b:
lahf
and ch,11011111b
XinstB
;***********************************************************
;* RES 6,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6b:
lahf
and ch,10111111b
XinstB
;***********************************************************
;* RES 7,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7b:
lahf
and ch,01111111b
XinstB
;***********************************************************
;* RES 0,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0c:
lahf
and cl,11111110b
XinstB
;***********************************************************
;* RES 1,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1c:
lahf
and cl,11111101b
XinstB
;***********************************************************
;* RES 2,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2c:
lahf
and cl,11111011b
XinstB
;***********************************************************
;* RES 3,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3c:
lahf
and cl,11110111b
XinstB
;***********************************************************
;* RES 4,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4c:
lahf
and cl,11101111b
XinstB
;***********************************************************
;* RES 5,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5c:
lahf
and cl,11011111b
XinstB
;***********************************************************
;* RES 6,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6c:
lahf
and cl,10111111b
XinstB
;***********************************************************
;* RES 7,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7c:
lahf
and cl,01111111b
XinstB
;***********************************************************
;* RES 0,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0d:
lahf
and dh,11111110b
XinstB
;***********************************************************
;* RES 1,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1d:
lahf
and dh,11111101b
XinstB
;***********************************************************
;* RES 2,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2d:
lahf
and dh,11111011b
XinstB
;***********************************************************
;* RES 3,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3d:
lahf
and dh,11110111b
XinstB
;***********************************************************
;* RES 4,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4d:
lahf
and dh,11101111b
XinstB
;***********************************************************
;* RES 5,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5d:
lahf
and dh,11011111b
XinstB
;***********************************************************
;* RES 6,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6d:
lahf
and dh,10111111b
XinstB
;***********************************************************
;* RES 7,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7d:
lahf
and dh,01111111b
XinstB
;***********************************************************
;* RES 0,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0e:
lahf
and dl,11111110b
XinstB
;***********************************************************
;* RES 1,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1e:
lahf
and dl,11111101b
XinstB
;***********************************************************
;* RES 2,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2e:
lahf
and dl,11111011b
XinstB
;***********************************************************
;* RES 3,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3e:
lahf
and dl,11110111b
XinstB
;***********************************************************
;* RES 4,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4e:
lahf
and dl,11101111b
XinstB
;***********************************************************
;* RES 5,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5e:
lahf
and dl,11011111b
XinstB
;***********************************************************
;* RES 6,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6e:
lahf
and dl,10111111b
XinstB
;***********************************************************
;* RES 7,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7e:
lahf
and dl,01111111b
XinstB
;***********************************************************
;* RES 0,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0h:
lahf
and bh,11111110b
XinstB
;***********************************************************
;* RES 1,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1h:
lahf
and bh,11111101b
XinstB
;***********************************************************
;* RES 2,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2h:
lahf
and bh,11111011b
XinstB
;***********************************************************
;* RES 3,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3h:
lahf
and bh,11110111b
XinstB
;***********************************************************
;* RES 4,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4h:
lahf
and bh,11101111b
XinstB
;***********************************************************
;* RES 5,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5h:
lahf
and bh,11011111b
XinstB
;***********************************************************
;* RES 6,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6h:
lahf
and bh,10111111b
XinstB
;***********************************************************
;* RES 7,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7h:
lahf
and bh,01111111b
XinstB
;***********************************************************
;* RES 0,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0l:
lahf
and bl,11111110b
XinstB
;***********************************************************
;* RES 1,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1l:
lahf
and bl,11111101b
XinstB
;***********************************************************
;* RES 2,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2l:
lahf
and bl,11111011b
XinstB
;***********************************************************
;* RES 3,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3l:
lahf
and bl,11110111b
XinstB
;***********************************************************
;* RES 4,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4l:
lahf
and bl,11101111b
XinstB
;***********************************************************
;* RES 5,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5l:
lahf
and bl,11011111b
XinstB
;***********************************************************
;* RES 6,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6l:
lahf
and bl,10111111b
XinstB
;***********************************************************
;* RES 7,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7l:
lahf
and bl,01111111b
XinstB
;***********************************************************
;* RES 0,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0a:
lahf
and al,11111110b
XinstB
;***********************************************************
;* RES 1,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1a:
lahf
and al,11111101b
XinstB
;***********************************************************
;* RES 2,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2a:
lahf
and al,11111011b
XinstB
;***********************************************************
;* RES 3,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3a:
lahf
and al,11110111b
XinstB
;***********************************************************
;* RES 4,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4a:
lahf
and al,11101111b
XinstB
;***********************************************************
;* RES 5,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5a:
lahf
and al,11011111b
XinstB
;***********************************************************
;* RES 6,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6a:
lahf
and al,10111111b
XinstB
;***********************************************************
;* RES 7,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7a:
lahf
and al,01111111b
XinstB
;***********************************************************
;* RES 0,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0z:
lahf
and BYTE [es:Z80+bx],11111110b
XinstB
;***********************************************************
;* RES 1,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1z:
lahf
and BYTE [es:Z80+bx],11111101b
XinstB
;***********************************************************
;* RES 2,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2z:
lahf
and BYTE [es:Z80+bx],11111011b
XinstB
;***********************************************************
;* RES 3,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3z:
lahf
and BYTE [es:Z80+bx],11110111b
XinstB
;***********************************************************
;* RES 4,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4z:
lahf
and BYTE [es:Z80+bx],11101111b
XinstB
;***********************************************************
;* RES 5,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5z:
lahf
and BYTE [es:Z80+bx],11011111b
XinstB
;***********************************************************
;* RES 6,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6z:
lahf
and BYTE [es:Z80+bx],10111111b
XinstB
;***********************************************************
;* RES 7,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7z:
lahf
and BYTE [es:Z80+bx],01111111b
XinstB
;***********************************************************
;* RES 0,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* RES 0,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES0w:
Z_RES0v:
lahf
and BYTE [es:Z80+si],11111110b
XinstB
;***********************************************************
;* RES 1,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* RES 1,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES1w:
Z_RES1v:
lahf
and BYTE [es:Z80+si],11111101b
XinstB
;***********************************************************
;* RES 2,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* RES 2,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES2w:
Z_RES2v:
lahf
and BYTE [es:Z80+si],11111011b
XinstB
;***********************************************************
;* RES 3,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* RES 3,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES3w:
Z_RES3v:
lahf
and BYTE [es:Z80+si],11110111b
XinstB
;***********************************************************
;* RES 4,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* RES 4,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES4w:
Z_RES4v:
lahf
and BYTE [es:Z80+si],11101111b
XinstB
;***********************************************************
;* RES 5,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* RES 5,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES5w:
Z_RES5v:
lahf
and BYTE [es:Z80+si],11011111b
XinstB
;***********************************************************
;* RES 6,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* RES 6,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES6w:
Z_RES6v:
lahf
and BYTE [es:Z80+si],10111111b
XinstB
;***********************************************************
;* RES 7,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* RES 7,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_RES7w:
Z_RES7v:
lahf
and BYTE [es:Z80+si],01111111b
XinstB
end

View File

@@ -0,0 +1,958 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Rotate and Shift Group *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_RLCw, Z_RRCw, Z_RLw, Z_RRw, Z_SLAw, Z_SRAw, Z_SRLw
GLOBAL Z_RLCv, Z_RRCv, Z_RLv, Z_RRv, Z_SLAv, Z_SRAv, Z_SRLv
GLOBAL Z_RLCA, Z_RRCA, Z_RLA, Z_RRA
GLOBAL Z_RLD, Z_RRD
GLOBAL Z_RLCb, Z_RLCc, Z_RLCd, Z_RLCe, Z_RLCh, Z_RLCl, Z_RLCz, Z_RLCa
GLOBAL Z_RRCb, Z_RRCc, Z_RRCd, Z_RRCe, Z_RRCh, Z_RRCl, Z_RRCz, Z_RRCa
GLOBAL Z_RLb, Z_RLc, Z_RLd, Z_RLe, Z_RLh, Z_RLl, Z_RLz, Z_RLa
GLOBAL Z_RRb, Z_RRc, Z_RRd, Z_RRe, Z_RRh, Z_RRl, Z_RRz, Z_RRa
GLOBAL Z_SLAb, Z_SLAc, Z_SLAd, Z_SLAe, Z_SLAh, Z_SLAl, Z_SLAz, Z_SLAa
GLOBAL Z_SRAb, Z_SRAc, Z_SRAd, Z_SRAe, Z_SRAh, Z_SRAl, Z_SRAz, Z_SRAa
GLOBAL Z_SRLb, Z_SRLc, Z_SRLd, Z_SRLe, Z_SRLh, Z_SRLl, Z_SRLz, Z_SRLa
; declared in INSTHAND.ASM
EXTERN Z80IX, Z80IY, FlagN
%include "macros.asm"
svebyt resb 1
;***********************************************************
;* RLCA Flags: S Z - H - P/V N C *
;* . . x 0 x . 0 ^ *
;***********************************************************
Z_RLCA:
rol al,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* RLA Flags: S Z - H - P/V N C *
;* . . x 0 x . 0 ^ *
;***********************************************************
Z_RLA:
rcl al,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* RRCA Flags: S Z - H - P/V N C *
;* . . x 0 x . 0 ^ *
;***********************************************************
Z_RRCA:
ror al,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* RRA Flags: S Z - H - P/V N C *
;* . . x 0 x . 0 ^ *
;***********************************************************
Z_RRA:
rcr al,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* RLC B Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCb:
rol ch,1
mov BYTE [FlagN],0
inc ch
dec ch
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RLC C Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCc:
rol cl,1
mov BYTE [FlagN],0
inc cl
dec cl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RLC D Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCd:
rol dh,1
mov BYTE [FlagN],0
inc dh
dec dh
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RLC E Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCe:
rol dl,1
mov BYTE [FlagN],0
inc dl
dec dl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RLC H Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCh:
rol bh,1
mov BYTE [FlagN],0
inc bh
dec bh
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RLC L Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCl:
rol bl,1
mov BYTE [FlagN],0
inc bl
dec bl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RLC A Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCa:
rol al,1
mov BYTE [FlagN],0
inc al
dec al
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RLC (HL) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCz:
rol BYTE [es:Z80+bx],1
mov BYTE [FlagN],0
inc BYTE [es:Z80+bx]
dec BYTE [es:Z80+bx]
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RLC (IX+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;* RLC (IY+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLCw:
Z_RLCv:
rol BYTE [es:Z80+si],1
mov BYTE [FlagN],0
inc BYTE [es:Z80+si]
dec BYTE [es:Z80+si]
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL B Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLb:
rcl ch,1
mov BYTE [FlagN],0
inc ch
dec ch
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL C Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLc:
rcl cl,1
mov BYTE [FlagN],0
inc cl
dec cl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL D Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLd:
rcl dh,1
mov BYTE [FlagN],0
inc dh
dec dh
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL E Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLe:
rcl dl,1
mov BYTE [FlagN],0
inc dl
dec dl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL H Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLh:
rcl bh,1
mov BYTE [FlagN],0
inc bh
dec bh
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL L Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLl:
rcl bl,1
mov BYTE [FlagN],0
inc bl
dec bl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL A Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLa:
rcl al,1
mov BYTE [FlagN],0
inc al
dec al
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL (HL) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLz:
rcl BYTE [es:Z80+bx],1
mov BYTE [FlagN],0
inc BYTE [es:Z80+bx]
dec BYTE [es:Z80+bx]
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RL (IX+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;* RL (IY+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RLw:
Z_RLv:
rcl BYTE [es:Z80+si],1
mov BYTE [FlagN],0
inc BYTE [es:Z80+si]
dec BYTE [es:Z80+si]
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC B Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCb:
ror ch,1
mov BYTE [FlagN],0
inc ch
dec ch
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC C Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCc:
ror cl,1
mov BYTE [FlagN],0
inc cl
dec cl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC D Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCd:
ror dh,1
mov BYTE [FlagN],0
inc dh
dec dh
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC E Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCe:
ror dl,1
mov BYTE [FlagN],0
inc dl
dec dl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC H Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCh:
ror bh,1
mov BYTE [FlagN],0
inc bh
dec bh
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC L Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCl:
ror bl,1
mov BYTE [FlagN],0
inc bl
dec bl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC A Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCa:
ror al,1
mov BYTE [FlagN],0
inc al
dec al
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC (HL) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCz:
ror BYTE [es:Z80+bx],1
mov BYTE [FlagN],0
inc BYTE [es:Z80+bx]
dec BYTE [es:Z80+bx]
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRC (IX+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;* RRC (IY+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRCw:
Z_RRCv:
ror BYTE [es:Z80+si],1
mov BYTE [FlagN],0
inc BYTE [es:Z80+si]
dec BYTE [es:Z80+si]
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR B Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRb:
rcr ch,1
mov BYTE [FlagN],0
inc ch
dec ch
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR C Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRc:
rcr cl,1
mov BYTE [FlagN],0
inc cl
dec cl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR D Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRd:
rcr dh,1
mov BYTE [FlagN],0
inc dh
dec dh
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR E Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRe:
rcr dl,1
mov BYTE [FlagN],0
inc dl
dec dl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR H Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRh:
rcr bh,1
mov BYTE [FlagN],0
inc bh
dec bh
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR L Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRl:
rcr bl,1
mov BYTE [FlagN],0
inc bl
dec bl
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR A Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRa:
rcr al,1
mov BYTE [FlagN],0
inc al
dec al
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR (HL) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRz:
rcr BYTE [es:Z80+bx],1
mov BYTE [FlagN],0
inc BYTE [es:Z80+bx]
dec BYTE [es:Z80+bx]
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RR (IX+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;* RR (IY+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_RRw:
Z_RRv:
rcr BYTE [es:Z80+si],1
mov BYTE [FlagN],0
inc BYTE [es:Z80+si]
dec BYTE [es:Z80+si]
lahf
and ah,11101111b
XinstB
;***********************************************************
;* SLA B Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAb:
shl ch,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SLA C Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAc:
shl cl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SLA D Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAd:
shl dh,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SLA E Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAe:
shl dl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SLA H Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAh:
shl bh,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SLA L Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAl:
shl bl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SLA A Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAa:
shl al,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SLA (HL) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAz:
shl BYTE [es:Z80+bx],1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SLA (IX+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;* SLA (IY+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SLAw:
Z_SLAv:
shl BYTE [es:Z80+si],1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA B Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAb:
sar ch,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA C Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAc:
sar cl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA D Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAd:
sar dh,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA E Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAe:
sar dl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA H Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAh:
sar bh,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA L Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAl:
sar bl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA A Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAa:
sar al,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA (HL) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAz:
sar BYTE [es:Z80+bx],1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRA (IX+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;* SRA (IY+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRAw:
Z_SRAv:
sar BYTE [es:Z80+si],1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL B Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLb:
shr ch,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL C Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLc:
shr cl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL D Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLd:
shr dh,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL E Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLe:
shr dl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL H Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLh:
shr bh,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL L Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLl:
shr bl,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL A Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLa:
shr al,1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL (HL) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLz:
shr BYTE [es:Z80+bx],1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* SRL (IX+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;* SRL (IY+NN) Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 ^ *
;***********************************************************
Z_SRLw:
Z_SRLv:
shr BYTE [es:Z80+si],1
lahf
and ah,11101111b
mov BYTE [FlagN],0
XinstB
;***********************************************************
;* RLD Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 . *
;***********************************************************
Z_RLD:
pushf ;must save C flag
mov [svebyt],al
and BYTE [svebyt],00001111b
and al,11110000b
mov ah,[es:Z80+bx]
shr ah,1
shr ah,1
shr ah,1
shr ah,1
shl BYTE [es:Z80+bx],1
shl BYTE [es:Z80+bx],1
shl BYTE [es:Z80+bx],1
shl BYTE [es:Z80+bx],1
or al,ah
mov ah,[svebyt]
or BYTE [es:Z80+bx],ah
popf
mov BYTE [FlagN],0
inc al
dec al
lahf
and ah,11101111b
XinstB
;***********************************************************
;* RRD Flags: S Z - H - P/V N C *
;* ^ ^ x 0 x P 0 . *
;***********************************************************
Z_RRD:
pushf ;must save C flag
mov [svebyt],al
shl BYTE [svebyt],1
shl BYTE [svebyt],1
shl BYTE [svebyt],1
shl BYTE [svebyt],1
and al,11110000b
mov ah,[es:Z80+bx]
and ah,00001111b
shr BYTE [es:Z80+bx],1
shr BYTE [es:Z80+bx],1
shr BYTE [es:Z80+bx],1
shr BYTE [es:Z80+bx],1
or al,ah
mov ah,[svebyt]
or BYTE [es:Z80+bx],ah
popf
mov BYTE [FlagN],0
inc al
dec al
lahf
and ah,11101111b
XinstB
end

View File

@@ -0,0 +1,736 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Bit Set Group *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Changed all uses of 'Z80' map segment to 'es:Z80'
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT Z80map public align=16
Z80:
SEGMENT .code public align=16
GLOBAL Z_SET0w, Z_SET1w, Z_SET2w, Z_SET3w, Z_SET4w, Z_SET5w, Z_SET6w, Z_SET7w
GLOBAL Z_SET0v, Z_SET1v, Z_SET2v, Z_SET3v, Z_SET4v, Z_SET5v, Z_SET6v, Z_SET7v
GLOBAL Z_SET0b, Z_SET0c, Z_SET0d, Z_SET0e, Z_SET0h, Z_SET0l, Z_SET0z, Z_SET0a
GLOBAL Z_SET1b, Z_SET1c, Z_SET1d, Z_SET1e, Z_SET1h, Z_SET1l, Z_SET1z, Z_SET1a
GLOBAL Z_SET2b, Z_SET2c, Z_SET2d, Z_SET2e, Z_SET2h, Z_SET2l, Z_SET2z, Z_SET2a
GLOBAL Z_SET3b, Z_SET3c, Z_SET3d, Z_SET3e, Z_SET3h, Z_SET3l, Z_SET3z, Z_SET3a
GLOBAL Z_SET4b, Z_SET4c, Z_SET4d, Z_SET4e, Z_SET4h, Z_SET4l, Z_SET4z, Z_SET4a
GLOBAL Z_SET5b, Z_SET5c, Z_SET5d, Z_SET5e, Z_SET5h, Z_SET5l, Z_SET5z, Z_SET5a
GLOBAL Z_SET6b, Z_SET6c, Z_SET6d, Z_SET6e, Z_SET6h, Z_SET6l, Z_SET6z, Z_SET6a
GLOBAL Z_SET7b, Z_SET7c, Z_SET7d, Z_SET7e, Z_SET7h, Z_SET7l, Z_SET7z, Z_SET7a
; declared in INSTHAND.ASM
EXTERN Z80IX, Z80IY
%include "macros.asm"
;***********************************************************
;* SET 0,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0b:
lahf
or ch,00000001b
XinstB
;***********************************************************
;* SET 1,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1b:
lahf
or ch,00000010b
XinstB
;***********************************************************
;* SET 2,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2b:
lahf
or ch,00000100b
XinstB
;***********************************************************
;* SET 3,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3b:
lahf
or ch,00001000b
XinstB
;***********************************************************
;* SET 4,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4b:
lahf
or ch,00010000b
XinstB
;***********************************************************
;* SET 5,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5b:
lahf
or ch,00100000b
XinstB
;***********************************************************
;* SET 6,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6b:
lahf
or ch,01000000b
XinstB
;***********************************************************
;* SET 7,B Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7b:
lahf
or ch,10000000b
XinstB
;***********************************************************
;* SET 0,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0c:
lahf
or cl,00000001b
XinstB
;***********************************************************
;* SET 1,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1c:
lahf
or cl,00000010b
XinstB
;***********************************************************
;* SET 2,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2c:
lahf
or cl,00000100b
XinstB
;***********************************************************
;* SET 3,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3c:
lahf
or cl,00001000b
XinstB
;***********************************************************
;* SET 4,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4c:
lahf
or cl,00010000b
XinstB
;***********************************************************
;* SET 5,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5c:
lahf
or cl,00100000b
XinstB
;***********************************************************
;* SET 6,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6c:
lahf
or cl,01000000b
XinstB
;***********************************************************
;* SET 7,C Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7c:
lahf
or cl,10000000b
XinstB
;***********************************************************
;* SET 0,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0d:
lahf
or dh,00000001b
XinstB
;***********************************************************
;* SET 1,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1d:
lahf
or dh,00000010b
XinstB
;***********************************************************
;* SET 2,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2d:
lahf
or dh,00000100b
XinstB
;***********************************************************
;* SET 3,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3d:
lahf
or dh,00001000b
XinstB
;***********************************************************
;* SET 4,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4d:
lahf
or dh,00010000b
XinstB
;***********************************************************
;* SET 5,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5d:
lahf
or dh,00100000b
XinstB
;***********************************************************
;* SET 6,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6d:
lahf
or dh,01000000b
XinstB
;***********************************************************
;* SET 7,D Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7d:
lahf
or dh,10000000b
XinstB
;***********************************************************
;* SET 0,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0e:
lahf
or dl,00000001b
XinstB
;***********************************************************
;* SET 1,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1e:
lahf
or dl,00000010b
XinstB
;***********************************************************
;* SET 2,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2e:
lahf
or dl,00000100b
XinstB
;***********************************************************
;* SET 3,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3e:
lahf
or dl,00001000b
XinstB
;***********************************************************
;* SET 4,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4e:
lahf
or dl,00010000b
XinstB
;***********************************************************
;* SET 5,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5e:
lahf
or dl,00100000b
XinstB
;***********************************************************
;* SET 6,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6e:
lahf
or dl,01000000b
XinstB
;***********************************************************
;* SET 7,E Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7e:
lahf
or dl,10000000b
XinstB
;***********************************************************
;* SET 0,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0h:
lahf
or bh,00000001b
XinstB
;***********************************************************
;* SET 1,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1h:
lahf
or bh,00000010b
XinstB
;***********************************************************
;* SET 2,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2h:
lahf
or bh,00000100b
XinstB
;***********************************************************
;* SET 3,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3h:
lahf
or bh,00001000b
XinstB
;***********************************************************
;* SET 4,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4h:
lahf
or bh,00010000b
XinstB
;***********************************************************
;* SET 5,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5h:
lahf
or bh,00100000b
XinstB
;***********************************************************
;* SET 6,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6h:
lahf
or bh,01000000b
XinstB
;***********************************************************
;* SET 7,H Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7h:
lahf
or bh,10000000b
XinstB
;***********************************************************
;* SET 0,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0l:
lahf
or bl,00000001b
XinstB
;***********************************************************
;* SET 1,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1l:
lahf
or bl,00000010b
XinstB
;***********************************************************
;* SET 2,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2l:
lahf
or bl,00000100b
XinstB
;***********************************************************
;* SET 3,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3l:
lahf
or bl,00001000b
XinstB
;***********************************************************
;* SET 4,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4l:
lahf
or bl,00010000b
XinstB
;***********************************************************
;* SET 5,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5l:
lahf
or bl,00100000b
XinstB
;***********************************************************
;* SET 6,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6l:
lahf
or bl,01000000b
XinstB
;***********************************************************
;* SET 7,L Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7l:
lahf
or bl,10000000b
XinstB
;***********************************************************
;* SET 0,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0a:
lahf
or al,00000001b
XinstB
;***********************************************************
;* SET 1,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1a:
lahf
or al,00000010b
XinstB
;***********************************************************
;* SET 2,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2a:
lahf
or al,00000100b
XinstB
;***********************************************************
;* SET 3,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3a:
lahf
or al,00001000b
XinstB
;***********************************************************
;* SET 4,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4a:
lahf
or al,00010000b
XinstB
;***********************************************************
;* SET 5,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5a:
lahf
or al,00100000b
XinstB
;***********************************************************
;* SET 6,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6a:
lahf
or al,01000000b
XinstB
;***********************************************************
;* SET 7,A Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7a:
lahf
or al,10000000b
XinstB
;***********************************************************
;* SET 0,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0z:
lahf
or BYTE [es:Z80+bx],00000001b
XinstB
;***********************************************************
;* SET 1,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1z:
lahf
or BYTE [es:Z80+bx],00000010b
XinstB
;***********************************************************
;* SET 2,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2z:
lahf
or BYTE [es:Z80+bx],00000100b
XinstB
;***********************************************************
;* SET 3,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3z:
lahf
or BYTE [es:Z80+bx],00001000b
XinstB
;***********************************************************
;* SET 4,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4z:
lahf
or BYTE [es:Z80+bx],00010000b
XinstB
;***********************************************************
;* SET 5,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5z:
lahf
or BYTE [es:Z80+bx],00100000b
XinstB
;***********************************************************
;* SET 6,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6z:
lahf
or BYTE [es:Z80+bx],01000000b
XinstB
;***********************************************************
;* SET 7,(HL) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7z:
lahf
or BYTE [es:Z80+bx],10000000b
XinstB
;***********************************************************
;* SET 0,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* SET 0,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET0w:
Z_SET0v:
lahf
or BYTE [es:Z80+si],00000001b
XinstB
;***********************************************************
;* SET 1,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* SET 1,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET1w:
Z_SET1v:
lahf
or BYTE [es:Z80+si],00000010b
XinstB
;***********************************************************
;* SET 2,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* SET 2,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET2w:
Z_SET2v:
lahf
or BYTE [es:Z80+si],00000100b
XinstB
;***********************************************************
;* SET 3,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* SET 3,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET3w:
Z_SET3v:
lahf
or BYTE [es:Z80+si],00001000b
XinstB
;***********************************************************
;* SET 4,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* SET 4,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET4w:
Z_SET4v:
lahf
or BYTE [es:Z80+si],00010000b
XinstB
;***********************************************************
;* SET 5,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* SET 5,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET5w:
Z_SET5v:
lahf
or BYTE [es:Z80+si],00100000b
XinstB
;***********************************************************
;* SET 6,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* SET 6,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET6w:
Z_SET6v:
lahf
or BYTE [es:Z80+si],01000000b
XinstB
;***********************************************************
;* SET 7,(IX+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;* SET 7,(IY+NN) Flags: S Z - H - P/V N C *
;* . . x . x . . . *
;***********************************************************
Z_SET7w:
Z_SET7v:
lahf
or BYTE [es:Z80+si],10000000b
XinstB
end

View File

@@ -0,0 +1,576 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Z80 Opcodes and Function Interface tables *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT .code public align=16
GLOBAL T0, T1, T2, T3, T4, T5, T6, T7, Tx
; declared in FUNCTION.ASM
EXTERN trp0__, trp1__, fnc___
EXTERN GtBoot
EXTERN blkcnt, blkget, blkput, blkfil
EXTERN GtZseg, intfnc
EXTERN GetByt, SetByt
EXTERN prmsta, prmget, vidsta, vidset
EXTERN usrbyt, failed, rstz80, extemu
; declared in HARDWARE.ASM
EXTERN bnkuse, bnksel, bnkmve, bnkdta
EXTERN bnkdma
EXTERN kbd1in, kbd1st, kbd1ip
EXTERN kbd2in, kbd2st, kbd2ip
EXTERN lptini, lptsta, lptout
EXTERN comini, comist, cominp, comost
EXTERN comout
EXTERN gettme, settme, getdte, setdte
EXTERN rdflop, wrflop, rdhard, wrhard
EXTERN GtHard, FlHard
; declared in VIDEO.ASM
EXTERN crt1in, crt1st, crt1op
EXTERN crt2in, crt2st, crt2op
;$CB opcodes for IX
EXTERN Z_RLCw, Z_RRCw, Z_RLw, Z_RRw
EXTERN Z_SLAw, Z_SRAw, Z_SRLw
EXTERN Z_BIT0w, Z_BIT1w, Z_BIT2w, Z_BIT3w
EXTERN Z_BIT4w, Z_BIT5w, Z_BIT6w, Z_BIT7w
EXTERN Z_RES0w, Z_RES1w, Z_RES2w, Z_RES3w
EXTERN Z_RES4w, Z_RES5w, Z_RES6w, Z_RES7w
EXTERN Z_SET0w, Z_SET1w, Z_SET2w, Z_SET3w
EXTERN Z_SET4w, Z_SET5w, Z_SET6w, Z_SET7w
;$CB opcodes for IY
EXTERN Z_RLCv, Z_RRCv, Z_RLv, Z_RRv
EXTERN Z_SLAv, Z_SRAv, Z_SRLv
EXTERN Z_BIT0v, Z_BIT1v, Z_BIT2v, Z_BIT3v
EXTERN Z_BIT4v, Z_BIT5v, Z_BIT6v, Z_BIT7v
EXTERN Z_RES0v, Z_RES1v, Z_RES2v, Z_RES3v
EXTERN Z_RES4v, Z_RES5v, Z_RES6v, Z_RES7v
EXTERN Z_SET0v, Z_SET1v, Z_SET2v, Z_SET3v
EXTERN Z_SET4v, Z_SET5v, Z_SET6v, Z_SET7v
;1st opcode for IX
EXTERN Z_ADxbc, Z_ADxde, Z_LDxn, Z_LDmx
EXTERN Z_INCx, Z_ADxx, Z_LDxm, Z_DECx
EXTERN Z_INCw, Z_DECw, Z_LDwn, Z_ADxsp
EXTERN Z_LDbw, Z_LDcw, Z_LDdw, Z_LDew
EXTERN Z_LDhw, Z_LDlw, Z_LDwb, Z_LDwc
EXTERN Z_LDwd, Z_LDwe, Z_LDwh, Z_LDwl
EXTERN Z_LDwa, Z_LDaw, Z_ADDw, Z_ADCw
EXTERN Z_SUBw, Z_SBCw, Z_ANDw, Z_XORw
EXTERN Z_ORw, Z_CPw, CBxops, Z_POPx
EXTERN Z_EXspx, Z_PUSHx, Z_JPx, Z_LDspx
;1st opcode for IY
EXTERN Z_ADybc, Z_ADyde, Z_LDyn, Z_LDmy
EXTERN Z_INCy, Z_ADyy, Z_LDym, Z_DECy
EXTERN Z_INCv, Z_DECv, Z_LDvn, Z_ADysp
EXTERN Z_LDbv, Z_LDcv, Z_LDdv, Z_LDev
EXTERN Z_LDhv, Z_LDlv, Z_LDvb, Z_LDvc
EXTERN Z_LDvd, Z_LDve, Z_LDvh, Z_LDvl
EXTERN Z_LDva, Z_LDav, Z_ADDv, Z_ADCv
EXTERN Z_SUBv, Z_SBCv, Z_ANDv, Z_XORv
EXTERN Z_ORv, Z_CPv, CByops, Z_POPy
EXTERN Z_EXspy, Z_PUSHy, Z_JPy, Z_LDspy
;$ED Opcode Table
EXTERN Z_INbc, Z_OUTcb, Z_SChlbc,Z_LDmbc
EXTERN Z_NEG, Z_RETN, Z_IM0, Z_LDia
EXTERN Z_INcc, Z_OUTcc, Z_AChlbc,Z_LDbcm
EXTERN Z_RETI, Z_LDra, Z_INdc, Z_OUTcd
EXTERN Z_SChlde,Z_LDmde, Z_IM1, Z_LDai
EXTERN Z_INec, Z_OUTce, Z_AChlde,Z_LDdem
EXTERN Z_IM2, Z_LDar, Z_INhc, Z_OUTch
EXTERN Z_SChlhl,Z_RRD, Z_INlc, Z_OUTcl
EXTERN Z_AChlhl,Z_RLD, Z_INfc, Z_SChlsp
EXTERN Z_LDmsp, Z_INac, Z_OUTca, Z_AChlsp
EXTERN Z_LDspm, Z_LDI, Z_CPI, Z_INI
EXTERN Z_OUTI, Z_LDD, Z_CPD, Z_IND
EXTERN Z_OUTD, Z_LDIR, Z_CPIR, Z_INIR
EXTERN Z_OTIR, Z_LDDR, Z_CPDR, Z_INDR
EXTERN Z_OTDR
;$CB opcode table
EXTERN Z_RLCb, Z_RLCc, Z_RLCd, Z_RLCe
EXTERN Z_RLCh, Z_RLCl, Z_RLCz, Z_RLCa
EXTERN Z_RRCb, Z_RRCc, Z_RRCd, Z_RRCe
EXTERN Z_RRCh, Z_RRCl, Z_RRCz, Z_RRCa
EXTERN Z_RLb, Z_RLc, Z_RLd, Z_RLe
EXTERN Z_RLh, Z_RLl, Z_RLz, Z_RLa
EXTERN Z_RRb, Z_RRc, Z_RRd, Z_RRe
EXTERN Z_RRh, Z_RRl, Z_RRz, Z_RRa
EXTERN Z_SLAb, Z_SLAc, Z_SLAd, Z_SLAe
EXTERN Z_SLAh, Z_SLAl, Z_SLAz, Z_SLAa
EXTERN Z_SRAb, Z_SRAc, Z_SRAd, Z_SRAe
EXTERN Z_SRAh, Z_SRAl, Z_SRAz, Z_SRAa
EXTERN Z_SRLb, Z_SRLc, Z_SRLd, Z_SRLe
EXTERN Z_SRLh, Z_SRLl, Z_SRLz, Z_SRLa
EXTERN Z_BIT0b, Z_BIT0c, Z_BIT0d, Z_BIT0e
EXTERN Z_BIT0h, Z_BIT0l, Z_BIT0z, Z_BIT0a
EXTERN Z_BIT1b, Z_BIT1c, Z_BIT1d, Z_BIT1e
EXTERN Z_BIT1h, Z_BIT1l, Z_BIT1z, Z_BIT1a
EXTERN Z_BIT2b, Z_BIT2c, Z_BIT2d, Z_BIT2e
EXTERN Z_BIT2h, Z_BIT2l, Z_BIT2z, Z_BIT2a
EXTERN Z_BIT3b, Z_BIT3c, Z_BIT3d, Z_BIT3e
EXTERN Z_BIT3h, Z_BIT3l, Z_BIT3z, Z_BIT3a
EXTERN Z_BIT4b, Z_BIT4c, Z_BIT4d, Z_BIT4e
EXTERN Z_BIT4h, Z_BIT4l, Z_BIT4z, Z_BIT4a
EXTERN Z_BIT5b, Z_BIT5c, Z_BIT5d, Z_BIT5e
EXTERN Z_BIT5h, Z_BIT5l, Z_BIT5z, Z_BIT5a
EXTERN Z_BIT6b, Z_BIT6c, Z_BIT6d, Z_BIT6e
EXTERN Z_BIT6h, Z_BIT6l, Z_BIT6z, Z_BIT6a
EXTERN Z_BIT7b, Z_BIT7c, Z_BIT7d, Z_BIT7e
EXTERN Z_BIT7h, Z_BIT7l, Z_BIT7z, Z_BIT7a
EXTERN Z_RES0b, Z_RES0c, Z_RES0d, Z_RES0e
EXTERN Z_RES0h, Z_RES0l, Z_RES0z, Z_RES0a
EXTERN Z_RES1b, Z_RES1c, Z_RES1d, Z_RES1e
EXTERN Z_RES1h, Z_RES1l, Z_RES1z, Z_RES1a
EXTERN Z_RES2b, Z_RES2c, Z_RES2d, Z_RES2e
EXTERN Z_RES2h, Z_RES2l, Z_RES2z, Z_RES2a
EXTERN Z_RES3b, Z_RES3c, Z_RES3d, Z_RES3e
EXTERN Z_RES3h, Z_RES3l, Z_RES3z, Z_RES3a
EXTERN Z_RES4b, Z_RES4c, Z_RES4d, Z_RES4e
EXTERN Z_RES4h, Z_RES4l, Z_RES4z, Z_RES4a
EXTERN Z_RES5b, Z_RES5c, Z_RES5d, Z_RES5e
EXTERN Z_RES5h, Z_RES5l, Z_RES5z, Z_RES5a
EXTERN Z_RES6b, Z_RES6c, Z_RES6d, Z_RES6e
EXTERN Z_RES6h, Z_RES6l, Z_RES6z, Z_RES6a
EXTERN Z_RES7b, Z_RES7c, Z_RES7d, Z_RES7e
EXTERN Z_RES7h, Z_RES7l, Z_RES7z, Z_RES7a
EXTERN Z_SET0b, Z_SET0c, Z_SET0d, Z_SET0e
EXTERN Z_SET0h, Z_SET0l, Z_SET0z, Z_SET0a
EXTERN Z_SET1b, Z_SET1c, Z_SET1d, Z_SET1e
EXTERN Z_SET1h, Z_SET1l, Z_SET1z, Z_SET1a
EXTERN Z_SET2b, Z_SET2c, Z_SET2d, Z_SET2e
EXTERN Z_SET2h, Z_SET2l, Z_SET2z, Z_SET2a
EXTERN Z_SET3b, Z_SET3c, Z_SET3d, Z_SET3e
EXTERN Z_SET3h, Z_SET3l, Z_SET3z, Z_SET3a
EXTERN Z_SET4b, Z_SET4c, Z_SET4d, Z_SET4e
EXTERN Z_SET4h, Z_SET4l, Z_SET4z, Z_SET4a
EXTERN Z_SET5b, Z_SET5c, Z_SET5d, Z_SET5e
EXTERN Z_SET5h, Z_SET5l, Z_SET5z, Z_SET5a
EXTERN Z_SET6b, Z_SET6c, Z_SET6d, Z_SET6e
EXTERN Z_SET6h, Z_SET6l, Z_SET6z, Z_SET6a
EXTERN Z_SET7b, Z_SET7c, Z_SET7d, Z_SET7e
EXTERN Z_SET7h, Z_SET7l, Z_SET7z, Z_SET7a
;1st opcode
EXTERN Z_NOP, Z_LDbcn, Z_LDbca, Z_INCbc
EXTERN Z_INCb, Z_DECb, Z_LDbn, Z_RLCA
EXTERN Z_EXafaf,Z_ADhlbc,Z_LDabc, Z_DECbc
EXTERN Z_INCc, Z_DECc, Z_LDcn, Z_RRCA
EXTERN Z_DJNZ, Z_LDden, Z_LDdea, Z_INCde
EXTERN Z_INCd, Z_DECd, Z_LDdn, Z_RLA
EXTERN Z_JR, Z_ADhlde,Z_LDade, Z_DECde
EXTERN Z_INCe, Z_DECe, Z_LDen, Z_RRA
EXTERN Z_JRNZ, Z_LDhln, Z_LDmhl, Z_INChl
EXTERN Z_INCh, Z_DECh, Z_LDhn, Z_DAA
EXTERN Z_JRZ, Z_ADhlhl,Z_LDhlm, Z_DEChl
EXTERN Z_INCl, Z_DECl, Z_LDln, Z_CPL
EXTERN Z_JRNC, Z_LDspn, Z_LDma, Z_INCsp
EXTERN Z_INCz, Z_DECz, Z_LDzn, Z_SCF
EXTERN Z_JRC, Z_ADhlsp,Z_LDam, Z_DECsp
EXTERN Z_INCa, Z_DECa, Z_LDan, Z_CCF
EXTERN Z_LDbb, Z_LDbc, Z_LDbd, Z_LDbe
EXTERN Z_LDbh, Z_LDbl, Z_LDbz, Z_LDba
EXTERN Z_LDcb, Z_LDcc, Z_LDcd, Z_LDce
EXTERN Z_LDch, Z_LDcl, Z_LDcz, Z_LDca
EXTERN Z_LDdb, Z_LDdc, Z_LDdd, Z_LDde
EXTERN Z_LDdh, Z_LDdl, Z_LDdz, Z_LDda
EXTERN Z_LDeb, Z_LDec, Z_LDed, Z_LDee
EXTERN Z_LDeh, Z_LDel, Z_LDez, Z_LDea
EXTERN Z_LDhb, Z_LDhc, Z_LDhd, Z_LDhe
EXTERN Z_LDhh, Z_LDhl, Z_LDhz, Z_LDha
EXTERN Z_LDlb, Z_LDlc, Z_LDld, Z_LDle
EXTERN Z_LDlh, Z_LDll, Z_LDlz, Z_LDla
EXTERN Z_LDzb, Z_LDzc, Z_LDzd, Z_LDze
EXTERN Z_LDzh, Z_LDzl, Z_HALT, Z_LDza
EXTERN Z_LDab, Z_LDac, Z_LDad, Z_LDae
EXTERN Z_LDah, Z_LDal, Z_LDaz, Z_LDaa
EXTERN Z_ADDb, Z_ADDc, Z_ADDd, Z_ADDe
EXTERN Z_ADDh, Z_ADDl, Z_ADDz, Z_ADDa
EXTERN Z_ADCb, Z_ADCc, Z_ADCd, Z_ADCe
EXTERN Z_ADCh, Z_ADCl, Z_ADCz, Z_ADCa
EXTERN Z_SUBb, Z_SUBc, Z_SUBd, Z_SUBe
EXTERN Z_SUBh, Z_SUBl, Z_SUBz, Z_SUBa
EXTERN Z_SBCb, Z_SBCc, Z_SBCd, Z_SBCe
EXTERN Z_SBCh, Z_SBCl, Z_SBCz, Z_SBCa
EXTERN Z_ANDb, Z_ANDc, Z_ANDd, Z_ANDe
EXTERN Z_ANDh, Z_ANDl, Z_ANDz, Z_ANDa
EXTERN Z_XORb, Z_XORc, Z_XORd, Z_XORe
EXTERN Z_XORh, Z_XORl, Z_XORz, Z_XORa
EXTERN Z_ORb, Z_ORc, Z_ORd, Z_ORe
EXTERN Z_ORh, Z_ORl, Z_ORz, Z_ORa
EXTERN Z_CPb, Z_CPc, Z_CPd, Z_CPe
EXTERN Z_CPh, Z_CPl, Z_CPz, Z_CPa
EXTERN Z_RETNZ, Z_POPbc, Z_JPNZ, Z_JP
EXTERN Z_CALLNZ,Z_PUSHbc,Z_ADDn, Z_RST0
EXTERN Z_RETZ, Z_RET, Z_JPZ, CBops
EXTERN Z_CALLZ, Z_CALL, Z_ADCn, Z_RST1
EXTERN Z_RETNC, Z_POPde, Z_JPNC, Z_8086
EXTERN Z_CALLNC,Z_PUSHde,Z_SUBn, Z_RST2
EXTERN Z_RETC, Z_EXX, Z_JPC, Z_INan
EXTERN Z_CALLC, IXops, Z_SBCn, Z_RST3
EXTERN Z_RETPO, Z_POPhl, Z_JPPO, Z_EXsphl
EXTERN Z_CALLPO,Z_PUSHhl,Z_ANDn, Z_RST4
EXTERN Z_RETPE, Z_JPhl, Z_JPPE, Z_EXdehl
EXTERN Z_CALLPE,EDops, Z_XORn, Z_RST5
EXTERN Z_RETP, Z_POPaf, Z_JPP, Z_DI
EXTERN Z_CALLP, Z_PUSHaf,Z_ORn, Z_RST6
EXTERN Z_RETM, Z_LDsphl,Z_JPM, Z_EI
EXTERN Z_CALLM, IYops, Z_CPn, Z_RST7
; 8086 high level interface functions
T7 dw kbd1in, kbd1st, kbd1ip, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw kbd2in, kbd2st, kbd2ip, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw crt1in, crt1st, crt1op, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw crt2in, crt2st, crt2op, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw lptini, lptsta, lptout, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw comini, comist, cominp, comost, comout, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw gettme, settme, getdte, setdte, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw rdflop, wrflop, rdhard, wrhard, GtBoot, GtHard, FlHard, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw blkcnt, blkget, blkput, blkfil, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw GtZseg, intfnc, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw GetByt, SetByt, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___, fnc___
dw bnkuse, bnksel, bnkmve, bnkdta, bnkdma, fnc___, fnc___, fnc___
dw prmsta, prmget, vidsta, vidset, usrbyt, failed, rstz80, extemu
; $CB opcodes for IX
;
T6 dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RLCw, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RRCw, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RLw, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RRw, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SLAw, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SRAw, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SRLw, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT0w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT1w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT2w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT3w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT4w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT5w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT6w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT7w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES0w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES1w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES2w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES3w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES4w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES5w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES6w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES7w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET0w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET1w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET2w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET3w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET4w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET5w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET6w, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET7w, trp0__
; $CB opcodes for IY
;
T5 dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RLCv, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RRCv, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RLv, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RRv, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SLAv, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SRAv, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SRLv, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT0v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT1v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT2v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT3v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT4v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT5v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT6v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_BIT7v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES0v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES1v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES2v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES3v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES4v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES5v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES6v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_RES7v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET0v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET1v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET2v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET3v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET4v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET5v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET6v, trp0__
dw trp0__, trp0__, trp0__, trp0__, trp0__, trp0__, Z_SET7v, trp0__
; 1st opcode for IX
;
T4 dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_ADxbc, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_ADxde, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_LDxn, Z_LDmx, Z_INCx, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_ADxx, Z_LDxm, Z_DECx, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, Z_INCw, Z_DECw, Z_LDwn, trp1__
dw trp1__, Z_ADxsp, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDbw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDcw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDdw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDew, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDhw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDlw, trp1__
dw Z_LDwb, Z_LDwc, Z_LDwd, Z_LDwe, Z_LDwh, Z_LDwl, trp1__, Z_LDwa
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDaw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_ADDw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_ADCw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_SUBw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_SBCw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_ANDw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_XORw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_ORw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_CPw, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, CBxops, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_POPx, trp1__, Z_EXspx, trp1__, Z_PUSHx, trp1__, trp1__
dw trp1__, Z_JPx, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_LDspx, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
; 1st opcode for IY
;
T3 dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_ADybc, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_ADyde, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_LDyn, Z_LDmy, Z_INCy, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_ADyy, Z_LDym, Z_DECy, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, Z_INCv, Z_DECv, Z_LDvn, trp1__
dw trp1__, Z_ADysp, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDbv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDcv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDdv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDev, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDhv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDlv, trp1__
dw Z_LDvb, Z_LDvc, Z_LDvd, Z_LDve, Z_LDvh, Z_LDvl, trp1__, Z_LDva
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_LDav, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_ADDv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_ADCv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_SUBv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_SBCv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_ANDv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_XORv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_ORv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, Z_CPv, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, CByops, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_POPy, trp1__, Z_EXspy, trp1__, Z_PUSHy, trp1__, trp1__
dw trp1__, Z_JPy, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, Z_LDspy, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
; $ED Opcode Table
;
T2 dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw Z_INbc, Z_OUTcb, Z_SChlbc,Z_LDmbc, Z_NEG, Z_RETN, Z_IM0, Z_LDia
dw Z_INcc, Z_OUTcc, Z_AChlbc,Z_LDbcm, trp1__, Z_RETI, trp1__, Z_LDra
dw Z_INdc, Z_OUTcd, Z_SChlde,Z_LDmde, trp1__, trp1__, Z_IM1, Z_LDai
dw Z_INec, Z_OUTce, Z_AChlde,Z_LDdem, trp1__, trp1__, Z_IM2, Z_LDar
dw Z_INhc, Z_OUTch, Z_SChlhl,trp1__, trp1__, trp1__, trp1__, Z_RRD
dw Z_INlc, Z_OUTcl, Z_AChlhl,trp1__, trp1__, trp1__, trp1__, Z_RLD
dw Z_INfc, trp1__, Z_SChlsp,Z_LDmsp, trp1__, trp1__, trp1__, trp1__
dw Z_INac, Z_OUTca, Z_AChlsp,Z_LDspm, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw Z_LDI, Z_CPI, Z_INI, Z_OUTI, trp1__, trp1__, trp1__, trp1__
dw Z_LDD, Z_CPD, Z_IND, Z_OUTD, trp1__, trp1__, trp1__, trp1__
dw Z_LDIR, Z_CPIR, Z_INIR, Z_OTIR, trp1__, trp1__, trp1__, trp1__
dw Z_LDDR, Z_CPDR, Z_INDR, Z_OTDR, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
; $CB opcode table
;
T1 dw Z_RLCb, Z_RLCc, Z_RLCd, Z_RLCe, Z_RLCh, Z_RLCl, Z_RLCz, Z_RLCa
dw Z_RRCb, Z_RRCc, Z_RRCd, Z_RRCe, Z_RRCh, Z_RRCl, Z_RRCz, Z_RRCa
dw Z_RLb, Z_RLc, Z_RLd, Z_RLe, Z_RLh, Z_RLl, Z_RLz, Z_RLa
dw Z_RRb, Z_RRc, Z_RRd, Z_RRe, Z_RRh, Z_RRl, Z_RRz, Z_RRa
dw Z_SLAb, Z_SLAc, Z_SLAd, Z_SLAe, Z_SLAh, Z_SLAl, Z_SLAz, Z_SLAa
dw Z_SRAb, Z_SRAc, Z_SRAd, Z_SRAe, Z_SRAh, Z_SRAl, Z_SRAz, Z_SRAa
dw trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__, trp1__
dw Z_SRLb, Z_SRLc, Z_SRLd, Z_SRLe, Z_SRLh, Z_SRLl, Z_SRLz, Z_SRLa
dw Z_BIT0b, Z_BIT0c, Z_BIT0d, Z_BIT0e, Z_BIT0h, Z_BIT0l, Z_BIT0z, Z_BIT0a
dw Z_BIT1b, Z_BIT1c, Z_BIT1d, Z_BIT1e, Z_BIT1h, Z_BIT1l, Z_BIT1z, Z_BIT1a
dw Z_BIT2b, Z_BIT2c, Z_BIT2d, Z_BIT2e, Z_BIT2h, Z_BIT2l, Z_BIT2z, Z_BIT2a
dw Z_BIT3b, Z_BIT3c, Z_BIT3d, Z_BIT3e, Z_BIT3h, Z_BIT3l, Z_BIT3z, Z_BIT3a
dw Z_BIT4b, Z_BIT4c, Z_BIT4d, Z_BIT4e, Z_BIT4h, Z_BIT4l, Z_BIT4z, Z_BIT4a
dw Z_BIT5b, Z_BIT5c, Z_BIT5d, Z_BIT5e, Z_BIT5h, Z_BIT5l, Z_BIT5z, Z_BIT5a
dw Z_BIT6b, Z_BIT6c, Z_BIT6d, Z_BIT6e, Z_BIT6h, Z_BIT6l, Z_BIT6z, Z_BIT6a
dw Z_BIT7b, Z_BIT7c, Z_BIT7d, Z_BIT7e, Z_BIT7h, Z_BIT7l, Z_BIT7z, Z_BIT7a
dw Z_RES0b, Z_RES0c, Z_RES0d, Z_RES0e, Z_RES0h, Z_RES0l, Z_RES0z, Z_RES0a
dw Z_RES1b, Z_RES1c, Z_RES1d, Z_RES1e, Z_RES1h, Z_RES1l, Z_RES1z, Z_RES1a
dw Z_RES2b, Z_RES2c, Z_RES2d, Z_RES2e, Z_RES2h, Z_RES2l, Z_RES2z, Z_RES2a
dw Z_RES3b, Z_RES3c, Z_RES3d, Z_RES3e, Z_RES3h, Z_RES3l, Z_RES3z, Z_RES3a
dw Z_RES4b, Z_RES4c, Z_RES4d, Z_RES4e, Z_RES4h, Z_RES4l, Z_RES4z, Z_RES4a
dw Z_RES5b, Z_RES5c, Z_RES5d, Z_RES5e, Z_RES5h, Z_RES5l, Z_RES5z, Z_RES5a
dw Z_RES6b, Z_RES6c, Z_RES6d, Z_RES6e, Z_RES6h, Z_RES6l, Z_RES6z, Z_RES6a
dw Z_RES7b, Z_RES7c, Z_RES7d, Z_RES7e, Z_RES7h, Z_RES7l, Z_RES7z, Z_RES7a
dw Z_SET0b, Z_SET0c, Z_SET0d, Z_SET0e, Z_SET0h, Z_SET0l, Z_SET0z, Z_SET0a
dw Z_SET1b, Z_SET1c, Z_SET1d, Z_SET1e, Z_SET1h, Z_SET1l, Z_SET1z, Z_SET1a
dw Z_SET2b, Z_SET2c, Z_SET2d, Z_SET2e, Z_SET2h, Z_SET2l, Z_SET2z, Z_SET2a
dw Z_SET3b, Z_SET3c, Z_SET3d, Z_SET3e, Z_SET3h, Z_SET3l, Z_SET3z, Z_SET3a
dw Z_SET4b, Z_SET4c, Z_SET4d, Z_SET4e, Z_SET4h, Z_SET4l, Z_SET4z, Z_SET4a
dw Z_SET5b, Z_SET5c, Z_SET5d, Z_SET5e, Z_SET5h, Z_SET5l, Z_SET5z, Z_SET5a
dw Z_SET6b, Z_SET6c, Z_SET6d, Z_SET6e, Z_SET6h, Z_SET6l, Z_SET6z, Z_SET6a
dw Z_SET7b, Z_SET7c, Z_SET7d, Z_SET7e, Z_SET7h, Z_SET7l, Z_SET7z, Z_SET7a
; 1st opcode
;
T0 dw Z_NOP, Z_LDbcn, Z_LDbca, Z_INCbc, Z_INCb, Z_DECb, Z_LDbn, Z_RLCA
dw Z_EXafaf,Z_ADhlbc,Z_LDabc, Z_DECbc, Z_INCc, Z_DECc, Z_LDcn, Z_RRCA
dw Z_DJNZ, Z_LDden, Z_LDdea, Z_INCde, Z_INCd, Z_DECd, Z_LDdn, Z_RLA
dw Z_JR, Z_ADhlde,Z_LDade, Z_DECde, Z_INCe, Z_DECe, Z_LDen, Z_RRA
dw Z_JRNZ, Z_LDhln, Z_LDmhl, Z_INChl, Z_INCh, Z_DECh, Z_LDhn, Z_DAA
dw Z_JRZ, Z_ADhlhl,Z_LDhlm, Z_DEChl, Z_INCl, Z_DECl, Z_LDln, Z_CPL
dw Z_JRNC, Z_LDspn, Z_LDma, Z_INCsp, Z_INCz, Z_DECz, Z_LDzn, Z_SCF
dw Z_JRC, Z_ADhlsp,Z_LDam, Z_DECsp, Z_INCa, Z_DECa, Z_LDan, Z_CCF
dw Z_LDbb, Z_LDbc, Z_LDbd, Z_LDbe, Z_LDbh, Z_LDbl, Z_LDbz, Z_LDba
dw Z_LDcb, Z_LDcc, Z_LDcd, Z_LDce, Z_LDch, Z_LDcl, Z_LDcz, Z_LDca
dw Z_LDdb, Z_LDdc, Z_LDdd, Z_LDde, Z_LDdh, Z_LDdl, Z_LDdz, Z_LDda
dw Z_LDeb, Z_LDec, Z_LDed, Z_LDee, Z_LDeh, Z_LDel, Z_LDez, Z_LDea
dw Z_LDhb, Z_LDhc, Z_LDhd, Z_LDhe, Z_LDhh, Z_LDhl, Z_LDhz, Z_LDha
dw Z_LDlb, Z_LDlc, Z_LDld, Z_LDle, Z_LDlh, Z_LDll, Z_LDlz, Z_LDla
dw Z_LDzb, Z_LDzc, Z_LDzd, Z_LDze, Z_LDzh, Z_LDzl, Z_HALT, Z_LDza
dw Z_LDab, Z_LDac, Z_LDad, Z_LDae, Z_LDah, Z_LDal, Z_LDaz, Z_LDaa
dw Z_ADDb, Z_ADDc, Z_ADDd, Z_ADDe, Z_ADDh, Z_ADDl, Z_ADDz, Z_ADDa
dw Z_ADCb, Z_ADCc, Z_ADCd, Z_ADCe, Z_ADCh, Z_ADCl, Z_ADCz, Z_ADCa
dw Z_SUBb, Z_SUBc, Z_SUBd, Z_SUBe, Z_SUBh, Z_SUBl, Z_SUBz, Z_SUBa
dw Z_SBCb, Z_SBCc, Z_SBCd, Z_SBCe, Z_SBCh, Z_SBCl, Z_SBCz, Z_SBCa
dw Z_ANDb, Z_ANDc, Z_ANDd, Z_ANDe, Z_ANDh, Z_ANDl, Z_ANDz, Z_ANDa
dw Z_XORb, Z_XORc, Z_XORd, Z_XORe, Z_XORh, Z_XORl, Z_XORz, Z_XORa
dw Z_ORb, Z_ORc, Z_ORd, Z_ORe, Z_ORh, Z_ORl, Z_ORz, Z_ORa
dw Z_CPb, Z_CPc, Z_CPd, Z_CPe, Z_CPh, Z_CPl, Z_CPz, Z_CPa
dw Z_RETNZ, Z_POPbc, Z_JPNZ, Z_JP, Z_CALLNZ,Z_PUSHbc,Z_ADDn, Z_RST0
dw Z_RETZ, Z_RET, Z_JPZ, CBops, Z_CALLZ, Z_CALL, Z_ADCn, Z_RST1
dw Z_RETNC, Z_POPde, Z_JPNC, Z_8086, Z_CALLNC,Z_PUSHde,Z_SUBn, Z_RST2
dw Z_RETC, Z_EXX, Z_JPC, Z_INan, Z_CALLC, IXops, Z_SBCn, Z_RST3
dw Z_RETPO, Z_POPhl, Z_JPPO, Z_EXsphl,Z_CALLPO,Z_PUSHhl,Z_ANDn, Z_RST4
dw Z_RETPE, Z_JPhl, Z_JPPE, Z_EXdehl,Z_CALLPE,EDops, Z_XORn, Z_RST5
dw Z_RETP, Z_POPaf, Z_JPP, Z_DI, Z_CALLP, Z_PUSHaf,Z_ORn, Z_RST6
dw Z_RETM, Z_LDsphl,Z_JPM, Z_EI, Z_CALLM, IYops, Z_CPn, Z_RST7
; 1st opcode table, COPY OF T0
;
Tx dw Z_NOP, Z_LDbcn, Z_LDbca, Z_INCbc, Z_INCb, Z_DECb, Z_LDbn, Z_RLCA
dw Z_EXafaf,Z_ADhlbc,Z_LDabc, Z_DECbc, Z_INCc, Z_DECc, Z_LDcn, Z_RRCA
dw Z_DJNZ, Z_LDden, Z_LDdea, Z_INCde, Z_INCd, Z_DECd, Z_LDdn, Z_RLA
dw Z_JR, Z_ADhlde,Z_LDade, Z_DECde, Z_INCe, Z_DECe, Z_LDen, Z_RRA
dw Z_JRNZ, Z_LDhln, Z_LDmhl, Z_INChl, Z_INCh, Z_DECh, Z_LDhn, Z_DAA
dw Z_JRZ, Z_ADhlhl,Z_LDhlm, Z_DEChl, Z_INCl, Z_DECl, Z_LDln, Z_CPL
dw Z_JRNC, Z_LDspn, Z_LDma, Z_INCsp, Z_INCz, Z_DECz, Z_LDzn, Z_SCF
dw Z_JRC, Z_ADhlsp,Z_LDam, Z_DECsp, Z_INCa, Z_DECa, Z_LDan, Z_CCF
dw Z_LDbb, Z_LDbc, Z_LDbd, Z_LDbe, Z_LDbh, Z_LDbl, Z_LDbz, Z_LDba
dw Z_LDcb, Z_LDcc, Z_LDcd, Z_LDce, Z_LDch, Z_LDcl, Z_LDcz, Z_LDca
dw Z_LDdb, Z_LDdc, Z_LDdd, Z_LDde, Z_LDdh, Z_LDdl, Z_LDdz, Z_LDda
dw Z_LDeb, Z_LDec, Z_LDed, Z_LDee, Z_LDeh, Z_LDel, Z_LDez, Z_LDea
dw Z_LDhb, Z_LDhc, Z_LDhd, Z_LDhe, Z_LDhh, Z_LDhl, Z_LDhz, Z_LDha
dw Z_LDlb, Z_LDlc, Z_LDld, Z_LDle, Z_LDlh, Z_LDll, Z_LDlz, Z_LDla
dw Z_LDzb, Z_LDzc, Z_LDzd, Z_LDze, Z_LDzh, Z_LDzl, Z_HALT, Z_LDza
dw Z_LDab, Z_LDac, Z_LDad, Z_LDae, Z_LDah, Z_LDal, Z_LDaz, Z_LDaa
dw Z_ADDb, Z_ADDc, Z_ADDd, Z_ADDe, Z_ADDh, Z_ADDl, Z_ADDz, Z_ADDa
dw Z_ADCb, Z_ADCc, Z_ADCd, Z_ADCe, Z_ADCh, Z_ADCl, Z_ADCz, Z_ADCa
dw Z_SUBb, Z_SUBc, Z_SUBd, Z_SUBe, Z_SUBh, Z_SUBl, Z_SUBz, Z_SUBa
dw Z_SBCb, Z_SBCc, Z_SBCd, Z_SBCe, Z_SBCh, Z_SBCl, Z_SBCz, Z_SBCa
dw Z_ANDb, Z_ANDc, Z_ANDd, Z_ANDe, Z_ANDh, Z_ANDl, Z_ANDz, Z_ANDa
dw Z_XORb, Z_XORc, Z_XORd, Z_XORe, Z_XORh, Z_XORl, Z_XORz, Z_XORa
dw Z_ORb, Z_ORc, Z_ORd, Z_ORe, Z_ORh, Z_ORl, Z_ORz, Z_ORa
dw Z_CPb, Z_CPc, Z_CPd, Z_CPe, Z_CPh, Z_CPl, Z_CPz, Z_CPa
dw Z_RETNZ, Z_POPbc, Z_JPNZ, Z_JP, Z_CALLNZ,Z_PUSHbc,Z_ADDn, Z_RST0
dw Z_RETZ, Z_RET, Z_JPZ, CBops, Z_CALLZ, Z_CALL, Z_ADCn, Z_RST1
dw Z_RETNC, Z_POPde, Z_JPNC, Z_8086, Z_CALLNC,Z_PUSHde,Z_SUBn, Z_RST2
dw Z_RETC, Z_EXX, Z_JPC, Z_INan, Z_CALLC, IXops, Z_SBCn, Z_RST3
dw Z_RETPO, Z_POPhl, Z_JPPO, Z_EXsphl,Z_CALLPO,Z_PUSHhl,Z_ANDn, Z_RST4
dw Z_RETPE, Z_JPhl, Z_JPPE, Z_EXdehl,Z_CALLPE,EDops, Z_XORn, Z_RST5
dw Z_RETP, Z_POPaf, Z_JPP, Z_DI, Z_CALLP, Z_PUSHaf,Z_ORn, Z_RST6
dw Z_RETM, Z_LDsphl,Z_JPM, Z_EI, Z_CALLM, IYops, Z_CPn, Z_RST7
end

View File

@@ -0,0 +1,388 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Video function support for Z80 system code *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
; Televideo 920/ADM-3A Video Terminal, DOS video service
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT .code public align=16
GLOBAL crt1in, crt1st, crt1op
GLOBAL crt2in, crt2st, crt2op
; declared in MAIN.ASM
EXTERN vidoff
%include "macros.asm"
;
;===============================================================================
; CRT #2 Video functions (STDOUT): Initialize, Status, Output
; crt2in:-
; crt2st:- Return: STDOUT status in reg A
; crt2op:- Pass: STDOUT character in reg C
;===============================================================================
crt2in: retn
crt2st: mov al,0ffh ;output always ready
retn
crt2op: cmp BYTE [vidoff],0 ;is video turned off ?
jz crt2o
retn
crt2o: mov ah,002h ;character output function
mov dl,cl ;character to reg DL
int 021h
retn
;===============================================================================
; CRT #1 Video functions: Initialize, Status, Output
; crt1in:-
; crt1st:- Return: status in reg A
; crt1op:- Pass: character in reg C
;===============================================================================
; Initialize CRT output driver
crt1in: mov BYTE [atrbyt],00000111b ;set video atributes to use
mov BYTE [atrflg],00000000b
mov BYTE [esccnt],0
mov cl,26
jmp crt1op ;clear screen
;
; Return CRT status in Z80 reg A
crt1st: mov al,0ffh ;return CRT always ready
retn
;
; Send character in Z80 reg C to CRT
crt1op: cmp BYTE [vidoff],0 ;is video turned off ?
jz crt1o
retn
crt1o: cmp BYTE [esccnt],0 ;any escape codes expected ?
jnz esccde
cmp cl,' ' ;control or printable character ?
jnc print0
xor ch,ch
mov di,cx
shl di,1
jmp WORD [ctltbl+di] ;jump to control character handler
;
setesc: mov BYTE [esccnt],1
retn
esccde: inc BYTE [esccnt]
cmp BYTE [esccnt],2
jnz escact
mov [escchr],cl ;save the 1st escape character
escact: mov al,[escchr]
xor ah,ah
mov di,ax
shl di,1
jmp WORD [esctbl+di] ;jump to escape sequence handler
;
esc___: mov BYTE [esccnt],0 ;unsupported escape codes here
jmp crt1op ;print the character
;
ctl___: retn ;unsupported control codes here
;
print0: mov ah,009h ;write char and attribute function
mov al,' '
mov bh,000h ;page #0
mov bl,[atrbyt] ;attribute value
mov dl,cl ;save the character to display
mov cx,1 ;write 1 character
int 010h
mov cl,dl ;restore the character to display
print1: mov ah,00eh ;write TTY function
mov al,cl ;character to AL
mov bh,000h ;page #0
int 010h
retn
;
hghint: mov BYTE [esccnt],0 ;no more escape codes follow
test BYTE [atrflg],00000100b ;is reverse video on ?
jnz inten1
test BYTE [atrflg],00000001b ;is underline on ?
mov ah,00001001b
jnz inten0
mov ah,00001111b
inten0: and BYTE [atrbyt],10000000b
or [atrbyt],ah
inten1: or BYTE [atrflg],00000010b ;set high intensity flag on
retn
;
lowint: mov BYTE [esccnt],0 ;no more escape codes follow
test BYTE [atrflg],00000100b ;is reverse video on ?
jnz inten3
test BYTE [atrflg],00000001b ;is underline on ?
mov ah,00000001b
jnz inten2
mov ah,00000111b
inten2: and BYTE [atrbyt],10000000b
or [atrbyt],ah
inten3: and BYTE [atrflg],11111101b ;set high intensity flag off
retn
;
blnkon: mov BYTE [esccnt],0 ;no more escape codes follow
or BYTE [atrbyt],10000000b
retn
;
blnkof: mov BYTE [esccnt],0 ;no more escape codes follow
and BYTE [atrbyt],01111111b
retn
;
rvseon: mov BYTE [esccnt],0 ;no more escape codes follow
or BYTE [atrflg],00000100b ;set reverse flag on
and BYTE [atrbyt],10000000b
or BYTE [atrbyt],01110000b
retn
;
rvseof: mov BYTE [esccnt],0 ;no more escape codes follow
and BYTE [atrflg],11111011b ;set reverse flag off
test BYTE [atrflg],00000010b ;set low or high intensity ?
jz lowint
jmp hghint
;
undron: mov BYTE [esccnt],0 ;no more escape codes follow
test BYTE [atrflg],00000100b
jnz under1
test BYTE [atrbyt],00001000b
mov ah,00001001b
jnz under0
mov ah,00000001b
under0: and BYTE [atrbyt],10000000b
or [atrbyt],ah
under1: or BYTE [atrflg],00000001b ;set underline flag on
retn
;
undrof: mov BYTE [esccnt],0 ;no more escape codes follow
test BYTE [atrflg],00000100b
jnz under3
test BYTE [atrbyt],00001000b
mov ah,00001111b
jnz under2
mov ah,00000111b
under2: and BYTE [atrbyt],11110000b
or [atrbyt],ah
under3: and BYTE [atrflg],11111110b ;set underline flag off
retn
;
setcur: cmp BYTE [esccnt],2
jnz stcur0
retn
stcur0: cmp BYTE [esccnt],3
jnz stcur1
mov [escdta],cl ;save Y cursor position
extcur: retn
stcur1: mov BYTE [esccnt],0 ;no more escape codes follow
mov dh,[escdta]
sub dh,' ' ;adjust (Y = 0 for 1st line)
cmp dh,25 ;is Y in range ?
jnc extcur
mov dl,cl
sub dl,' ' ;adjust (X = 0 for 1st column)
cmp dl,80 ;is X in range ?
jnc extcur
jmp cursor
;
clreos: mov BYTE [esccnt],0 ;no more escape codes follow
mov ah,003h ;read cursor position function
mov bh,000h ;page #0
int 010h
cmp dh,25
jc clesc0
retn
clesc0: cmp dl,80
jc clesc1
retn
clesc1: mov al,80
mul dh
mov dh,0
add ax,dx
mov cx,2000
sub cx,ax ;number of characters to clear
jmp scrclr
;
clreol: mov BYTE [esccnt],0 ;no more escape codes follow
mov ah,003h ;read cursor position function
mov bh,000h ;page #0
int 010h
cmp dl,80
jc clrlne
retn
clrlne: mov cx,80
mov dh,0
sub cx,dx ;number of characters to clear
scrclr: mov ah,009h ;write char and attribute function
mov al,' '
mov bh,000h ;page #0
mov bl,007h ;attribute value
int 010h
retn
;
lneins: mov BYTE [esccnt],0 ;no more escape codes follow
mov ah,003h ;read cursor position function
mov bh,000h ;page #0
int 010h
mov ch,dh
mov cl,0
mov dh,24
mov dl,79
mov ah,007h ;scroll page down function
mov al,1 ;lines to blank
mov bh,07h ;attribute for blank
int 010h
retn
;
lnedel: mov BYTE [esccnt],0 ;no more escape codes follow
mov ah,003h ;read cursor position function
mov bh,000h ;page #0
int 010h
mov ch,dh
mov cl,0
mov dh,24
mov dl,79
mov ah,006h ;scroll page up function
mov al,1 ;lines to blank
mov bh,07h ;attribute for blank
int 010h
retn
;
clrscr: mov BYTE [esccnt],0 ;no more escape codes follow
mov ah,005h ;select active page for func #6, #7
mov al,0 ;page #0
int 010h
mov cx,0 ;top X and Y co-ordinates
mov dh,24 ;bottom Y co-ordinate
mov dl,79 ;bottom X co-ordinate
mov ah,006h ;scroll page up function
mov al,0 ;clear entire display
mov bh,07h ;attribute for blank
int 010h ;fall through to home cursor
;
hmecur: mov dx,0000h ;set cursor to 0, 0
cursor: mov ah,002h
mov bh,000h
int 010h
retn
;
vertab: mov ah,003h ;read cursor position function
mov bh,000h ;page #0
int 010h
cmp dh,0 ;is cursor Y on 1st line ?
jnz moveup
retn
moveup: dec dh ;decrement cursor Y
jmp cursor ;and set cursor
;
hortab: mov ah,003h ;read cursor position function
mov bh,000h ;page #0
int 010h
and dl,7
neg dl
add dl,8
nxtspc: mov ah,009h ;write char and attribute function
mov al,' '
mov bh,000h ;page #0
mov bl,[atrbyt] ;attribute value
mov cx,1 ;write 1 character
int 010h
mov ah,00eh ;write TTY function
mov al,' '
mov bh,000h ;page #0
int 010h
dec dl ;decrement tab counter
jnz nxtspc
retn
;
curfwd: mov ah,003h ;read cursor position function
mov bh,000h ;page #0
int 010h
cmp dl,79
jnc newlne
inc dl ;increment cursor X
jmp cursor ;and set cursor
newlne: mov dl,0 ;set cursor X to zero
mov ah,002h
mov bh,000h
int 010h
mov cl,00ah ;line feed character
jmp crt1op ;print it
;
esccnt db 0
escchr db 0
escdta db 0
atrbyt db 00000111b
atrflg db 00000000b
;
ctltbl dw ctl___, ctl___, ctl___, ctl___, ctl___, ctl___, ctl___, print1
dw print1, hortab, print1, vertab, curfwd, print1, ctl___, ctl___
dw ctl___, rvseof, ctl___, ctl___, ctl___, ctl___, ctl___, ctl___
dw ctl___, rvseon, clrscr, setesc, ctl___, ctl___, hmecur, ctl___
;
esctbl dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw lowint, hghint, clrscr, clrscr, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, setcur, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, lneins, esc___, esc___
dw esc___, esc___, rvseon, rvseof, undron, undrof, esc___, esc___
dw esc___, blnkof, lnedel, esc___, clreol, esc___, esc___, esc___
dw esc___, clreos, esc___, esc___, esc___, esc___, blnkon, esc___
dw esc___, esc___, esc___, esc___, esc___, lneins, esc___, esc___
dw esc___, esc___, rvseon, rvseof, undron, undrof, esc___, esc___
dw esc___, blnkof, lnedel, esc___, clreol, esc___, esc___, esc___
dw esc___, clreos, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
dw esc___, esc___, esc___, esc___, esc___, esc___, esc___, esc___
;
end

View File

@@ -0,0 +1,458 @@
;*******************************************************************************
;* z80em86 *
;* A Z80 CPU emulator coded in Intel 86 assembly language *
;* *
;* Window and Screen Output support for error messages *
;* *
;* Copyright (C) 1992-2009 Stewart Kay *
;*******************************************************************************
;
;===============================================================================
; ChangeLog (most recent entries are at top)
;===============================================================================
; v1.0.0 - 10 February 2009, S.J.Kay
; - Convert sources from TASM to NASM format and prepare for GPL release.
; - Added 'align=16' to all SEGMENT declarations. (nasm def is align=1)
;
; v1.00 - 29 April 1995 S.J.Kay
; - Last time code was worked on before releasing under the GPL.
;
; v0.00 - 1992 S.J.Kay
; - Started to code the Z80 emulator.
;===============================================================================
; 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
;===============================================================================
SEGMENT .code public align=16
GLOBAL OpnWnd, ClsWnd
GLOBAL PrnByt, PrnHex, PrnStr, PrnChr, EraScr, HdeCur
GLOBAL GetAct, GetKey
; declared in MAIN.ASM
EXTERN VidSeg, VidBuf, prmflg
%include "macros.asm"
;===============================================================================
; Window box
; Pass: dh=window Y start
; dl=window X start
; ch=window Y finish
; cl=window X finish
; Return: nothing
;===============================================================================
OpnWnd: pushf
push ax
push bx
push si
push di
mov al,[WndNmb]
cmp al,4
jnz setwnd
jmp wndful
setwnd: push cx
push dx
xor ah,ah
mov di,ax
shl di,1
mov ah,003h ;read cursor position function
mov bh,000h ;page #0
int 010h
mov WORD [SveCur+di],dx ;save current cursor position
mov cx,4000
mov al,[WndNmb]
xor ah,ah
mul cx
mov di,ax
xor si,si
push ds
push es
mov es,[VidBuf]
mov ds,[VidSeg]
cld
rep movsb
pop es
pop ds
pop dx
pop cx
inc BYTE [WndNmb]
call WndBox
wndful: pop di
pop si
pop bx
pop ax
popf
retn
;===============================================================================
; Window close
; Pass: nothing
; Return: nothing
;===============================================================================
ClsWnd: pushf
push ax
push bx
push cx
push dx
push si
push di
mov al,[WndNmb]
or al,al
jnz reswnd
jmp notwnd
reswnd: dec al
mov [WndNmb],al
xor ah,ah
mov di,ax
shl di,1
mov dx,[SveCur+di] ;get cursor position
mov ah,002h ;set cursor function
mov bh,000h ;page #0
int 010h
mov cx,4000
mov al,[WndNmb]
xor ah,ah
mul cx
mov si,ax
xor di,di
push ds
push es
mov es,[VidSeg]
mov ds,[VidBuf]
cld
rep movsb
pop es
pop ds
notwnd: pop di
pop si
pop dx
pop cx
pop bx
pop ax
popf
retn
WndBox: pushf
push ax
push bx
mov [WndX0],dl
mov [WndY0],dh
mov [WndX1],cl
mov [WndY1],ch
sub ch,dh
dec ch
mov [BoxDep],ch
sub cl,dl
dec cl
mov [BoxWid],cl
mov ah,002h ;set cursor function
mov bh,000h ;page #0
int 010h
mov BYTE [BoxCh0],201
mov BYTE [BoxCh1],205
mov BYTE [BoxCh2],187
call DrwBox
mov ch,[BoxDep]
or ch,ch
jz BoxBot
mov BYTE [BoxCh0],186
mov BYTE [BoxCh1],' '
mov BYTE [BoxCh2],186
BoxDwn: call DrwBox
dec ch
jnz BoxDwn
BoxBot: mov BYTE [BoxCh0],200
mov BYTE [BoxCh1],205
mov BYTE [BoxCh2],188
call DrwBox
mov dl,[WndX0] ;top X position of window
add dl,2 ;start text 2 positions in
mov dh,[WndY0] ;top Y position of window
inc dh ;start text on next line
mov ah,002h ;set cursor function
int 010h
pop bx
pop ax
popf
retn
DrwBox: push cx
mov ah,009h ;write char and attribute function
mov bh,000h ;page #0
mov bl,070h ;attribute value
mov al,[BoxCh0]
mov cx,1 ;write 1 character
int 010h
mov ah,003h ;read cursor position function
inc dl
mov ah,002h ;set cursor function
int 010h
mov ah,009h ;write char and attribute function
mov al,[BoxCh1]
xor ch,ch ;write ? characters
mov cl,[BoxWid]
int 010h
add dl,cl
mov ah,002h ;set cursor function
int 010h
mov ah,009h ;write char and attribute function
mov al,[BoxCh2]
mov cx,1 ;write 1 character
int 010h
mov dl,[WndX0]
inc dh ;draw window on next line
mov ah,002h ;set cursor function
int 010h
pop cx
retn
;===============================================================================
; Print string
; Pass:
; Return: nothing
;===============================================================================
PrnStr: pushf
push ax
push si
PrnLp: mov al,[si]
inc si
cmp al,'$'
jz PrnExt
call PrnChr
jmp PrnLp
PrnExt: pop si
pop ax
popf
retn
;===============================================================================
; Print byte
; Pass:
; Return: nothing
;===============================================================================
PrnByt: pushf
push ax
push bx
mov bl,100
xor ah,ah
div bl
or al,al
jz PrnBy1
add al,'0'
call PrnChr ;print hundreds digit
PrnBy1: mov al,ah ;remainder
mov bl,10
xor ah,ah
div bl
or al,al
jz PrnBy2
add al,'0'
call PrnChr ;print tens digits
PrnBy2: mov al,ah ;remainder
add al,'0'
call PrnChr ;print units
pop bx
pop ax
popf
retn
;===============================================================================
; Print hex
; Pass:
; Return: nothing
;===============================================================================
PrnHex: pushf
push ax
push cx
mov ch,al
mov cl,4
shr al,cl
add al,'0'
cmp al,':'
jc Hex0
add al,007h
Hex0: call PrnChr
mov al,ch
and al,00fh
add al,'0'
cmp al,':'
jc Hex1
add al,007h
Hex1: call PrnChr
pop cx
pop ax
popf
retn
PrnChr: pushf
push ax
push bx
push cx
push dx
mov bh,000h ;page #0
mov dl,al ;save the character to display
cmp al,' '
jc PrnCh1
mov ah,009h ;write char and attribute function
mov bl,070h ;attribute value
mov cx,1 ;write 1 character
int 010h
PrnCh1: mov al,dl ;restore the character to display
cmp al,00dh
jz PrnCh2
cmp al,00ah
jz PrnCh3
mov ah,00eh ;write TTY function
jmp PrnCh4
PrnCh2: mov ah,003h ;read cursor position function
int 010h
mov dl,[WndX0]
add dl,2
mov ah,002h ;set cursor function
jmp PrnCh4
PrnCh3: mov ah,003h ;read cursor position function
int 010h
inc dh
mov ah,002h ;set cursor function
PrnCh4: int 010h
pop dx
pop cx
pop bx
pop ax
popf
retn
;===============================================================================
; Erase screen
; Pass:
; Return: nothing
;===============================================================================
EraScr: pushf
cmp BYTE [prmflg],0ffh
jz skpcls ;skip CLS if command tail
push ax
push bx
push cx
mov ah,005h ;select active page for func #6, #7
xor al,al ;page #0
int 010h
xor cx,cx ;top X and Y co-ordinates
mov dh,24 ;bottom Y co-ordinate
mov dl,79 ;bottom X co-ordinate
mov ah,006h ;scroll page up function
xor al,al ;entire display cleared if 0
mov bh,007h ;attribute for blank
int 010h ;fall through to home cursor
xor dx,dx ;set cursor to 0, 0
mov ah,002h
xor bh,bh ;page #0
int 010h
pop cx
pop bx
pop ax
skpcls: popf
retn
;===============================================================================
; Hide cursor
; Pass: nothing
; Return: nothing
;===============================================================================
HdeCur: push ax
push bx
push dx
mov dx,0ffffh ;cursor position
mov ah,002h ;set cursor function
mov bh,000h ;page #0
int 010h
pop dx
pop bx
pop ax
retn
;===============================================================================
; Get user key action
; Pass: nothing
; Return: AL=requested action
;===============================================================================
GetAct: call GetKey ;return key in reg AL
push ax ;save key pressed
call PrnChr ;print user's selection
GetRet: call keyinp
cmp al,008h
jnz notbck
call PrnChr
mov al,' '
call PrnChr
mov al,008h
call PrnChr
pop ax ;dump key
jmp GetAct ;retry again for another key
notbck: cmp al,00dh ;ENTER key pressed ?
jnz GetRet
pop ax
and al,11011111b ;convert to upper case
retn
;===============================================================================
; Get user key action
; Pass:
; Return: al=key
;===============================================================================
GetKey: push dx ;returns key in reg AL
nxttry: call keyinp
push si
mov dl,al
and dl,11011111b ;convert to upper case
nxtkey: cmp byte[si],dl
jz gotkey
inc si
cmp byte[si],'$'
jnz nxtkey
pop si
jmp nxttry
gotkey: pop si
pop dx
retn
keyinp: mov ah,001h ;get keyboard status function
int 016h
jz empbuf
mov ah,000h ;read key from keybaud function
int 016h
jmp keyinp ;empty keyboard buffer
empbuf: mov ah,000h ;read key from keybaud function
int 016h
retn ;keyboard key in AL
SveCur resw 4
WndNmb db 0
WndX0 resb 1
WndY0 resb 1
WndX1 resb 1
WndY1 resb 1
BoxCh0 resb 1
BoxCh1 resb 1
BoxCh2 resb 1
BoxDep resb 1
BoxWid resb 1
end

View File

@@ -0,0 +1,78 @@
(*************************************************************************)
(* *)
(* Z80 Hard Disk v1.00 *)
(* (C) Copyright S.J.Kay 6th December 1993 *)
(* *)
(* Creates a disk file to be used by the Z80 Emulator *)
(* program as a hard disk. *)
(* *)
(*************************************************************************)
uses
crt, dos;
const
HDDMEG = 4; { size of HDD file in Mbytes }
SECSZE = 512;
SECTRK = 64;
HDDSEC = (HDDMEG * 1024) * (1024 div SECSZE);
FLENME = 'Z80HDD.DSK';
MkeDrv : boolean = true;
var
F : file;
i : integer;
Sector : array [0..SECSZE-1] of byte;
DrvPth : string[80];
ChkUsr : string[1];
begin
clrscr;
writeln;
writeln('===================================================');
writeln('Z80 Hard Disk v1.00 (C) Copyright S.J.Kay 6/12/93');
writeln;
writeln('Creates a disk file to be used by the Z80 Emulator');
writeln(' program as a hard disk');
writeln('===================================================');
writeln;
writeln('Hard disk size: ', HDDMEG, ' Megabytes');
writeln;
write('Enter drive path: ');
readln(DrvPth);
writeln;
if (DrvPth <> '') and (not(DrvPth[length(DrvPth)] in [':', '\'])) then
DrvPth := DrvPth + '\';
assign(F, DrvPth + FLENME);
Setfattr(F, 0); { make file read/write }
{$I-}
reset(F);
if ioresult = 0 then
begin
close(F);
{$I+}
writeln('WARNING - ', DrvPth + FLENME, ' will be lost forever');
write( 'Do you wish to continue (y/n) ?: ');
readln(ChkUsr);
MkeDrv := (ChkUsr= 'Y') or (ChkUsr = 'y');
writeln
end;
if MkeDrv then
begin
writeln('Creating ', DrvPth + FLENME);
writeln;
rewrite(F, SECSZE);
fillchar(Sector, SECSZE, $E5);
for i := 1 to HDDSEC do
begin
blockwrite(F, Sector, 1);
if i mod SECTRK = 0 then
write(^M, i:5, ' of ', HDDSEC)
end;
close(F);
writeln;
writeln;
writeln('Z80 hard disk file created')
end;
Setfattr(F, ReadOnly);
end.