Browse Source

Initial revision

Hampa Hug 16 years ago
commit
a92fe21519
36 changed files with 31049 additions and 0 deletions
  1. 1
    0
      AUTHORS
  2. 280
    0
      COPYING
  3. 226
    0
      INSTALL
  4. 12
    0
      Makefile.in
  5. 91
    0
      Makefile.inc.in
  6. 3
    0
      NEWS
  7. 0
    0
      README
  8. 0
    0
      TODO
  9. 100
    0
      configure.in
  10. 250
    0
      install-sh
  11. 14
    0
      pce.lsm
  12. 56
    0
      src/Makefile.in
  13. 45
    0
      src/bios/Makefile.in
  14. 15596
    0
      src/bios/basic.asm
  15. 4738
    0
      src/bios/bios.asm
  16. 195
    0
      src/bios/pce.asm
  17. 40
    0
      src/config.h.in
  18. 42
    0
      src/e8086/Makefile.in
  19. 1844
    0
      src/e8086/disasm.c
  20. 339
    0
      src/e8086/e8086.c
  21. 158
    0
      src/e8086/e8086.h
  22. 381
    0
      src/e8086/ea.c
  23. 145
    0
      src/e8086/internal.h
  24. 4244
    0
      src/e8086/microcode.c
  25. 223
    0
      src/floppy.c
  26. 49
    0
      src/floppy.h
  27. 142
    0
      src/ibmpc.c
  28. 59
    0
      src/ibmpc.h
  29. 297
    0
      src/keyboard.c
  30. 61
    0
      src/keyboard.h
  31. 229
    0
      src/mda.c
  32. 61
    0
      src/mda.h
  33. 226
    0
      src/memory.c
  34. 73
    0
      src/memory.h
  35. 780
    0
      src/pce.c
  36. 49
    0
      src/pce.h

+ 1
- 0
AUTHORS View File

@@ -0,0 +1 @@
1
+Hampa Hug <hampa@hampa.ch>

+ 280
- 0
COPYING View File

@@ -0,0 +1,280 @@
1
+		    GNU GENERAL PUBLIC LICENSE
2
+		       Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+		       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+			    Preamble
10
+
11
+  The licenses for most software are designed to take away your
12
+freedom to share and change it.  By contrast, the GNU General Public
13
+License is intended to guarantee your freedom to share and change free
14
+software--to make sure the software is free for all its users.  This
15
+General Public License applies to most of the Free Software
16
+Foundation's software and to any other program whose authors commit to
17
+using it.  (Some other Free Software Foundation software is covered by
18
+the GNU Library General Public License instead.)  You can apply it to
19
+your programs, too.
20
+
21
+  When we speak of free software, we are referring to freedom, not
22
+price.  Our General Public Licenses are designed to make sure that you
23
+have the freedom to distribute copies of free software (and charge for
24
+this service if you wish), that you receive source code or can get it
25
+if you want it, that you can change the software or use pieces of it
26
+in new free programs; and that you know you can do these things.
27
+
28
+  To protect your rights, we need to make restrictions that forbid
29
+anyone to deny you these rights or to ask you to surrender the rights.
30
+These restrictions translate to certain responsibilities for you if you
31
+distribute copies of the software, or if you modify it.
32
+
33
+  For example, if you distribute copies of such a program, whether
34
+gratis or for a fee, you must give the recipients all the rights that
35
+you have.  You must make sure that they, too, receive or can get the
36
+source code.  And you must show them these terms so they know their
37
+rights.
38
+
39
+  We protect your rights with two steps: (1) copyright the software, and
40
+(2) offer you this license which gives you legal permission to copy,
41
+distribute and/or modify the software.
42
+
43
+  Also, for each author's protection and ours, we want to make certain
44
+that everyone understands that there is no warranty for this free
45
+software.  If the software is modified by someone else and passed on, we
46
+want its recipients to know that what they have is not the original, so
47
+that any problems introduced by others will not reflect on the original
48
+authors' reputations.
49
+
50
+  Finally, any free program is threatened constantly by software
51
+patents.  We wish to avoid the danger that redistributors of a free
52
+program will individually obtain patent licenses, in effect making the
53
+program proprietary.  To prevent this, we have made it clear that any
54
+patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+  The precise terms and conditions for copying, distribution and
57
+modification follow.
58
+
59
+		    GNU GENERAL PUBLIC LICENSE
60
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+  0. This License applies to any program or other work which contains
63
+a notice placed by the copyright holder saying it may be distributed
64
+under the terms of this General Public License.  The "Program", below,
65
+refers to any such program or work, and a "work based on the Program"
66
+means either the Program or any derivative work under copyright law:
67
+that is to say, a work containing the Program or a portion of it,
68
+either verbatim or with modifications and/or translated into another
69
+language.  (Hereinafter, translation is included without limitation in
70
+the term "modification".)  Each licensee is addressed as "you".
71
+
72
+Activities other than copying, distribution and modification are not
73
+covered by this License; they are outside its scope.  The act of
74
+running the Program is not restricted, and the output from the Program
75
+is covered only if its contents constitute a work based on the
76
+Program (independent of having been made by running the Program).
77
+Whether that is true depends on what the Program does.
78
+
79
+  1. You may copy and distribute verbatim copies of the Program's
80
+source code as you receive it, in any medium, provided that you
81
+conspicuously and appropriately publish on each copy an appropriate
82
+copyright notice and disclaimer of warranty; keep intact all the
83
+notices that refer to this License and to the absence of any warranty;
84
+and give any other recipients of the Program a copy of this License
85
+along with the Program.
86
+
87
+You may charge a fee for the physical act of transferring a copy, and
88
+you may at your option offer warranty protection in exchange for a fee.
89
+
90
+  2. You may modify your copy or copies of the Program or any portion
91
+of it, thus forming a work based on the Program, and copy and
92
+distribute such modifications or work under the terms of Section 1
93
+above, provided that you also meet all of these conditions:
94
+
95
+    a) You must cause the modified files to carry prominent notices
96
+    stating that you changed the files and the date of any change.
97
+
98
+    b) You must cause any work that you distribute or publish, that in
99
+    whole or in part contains or is derived from the Program or any
100
+    part thereof, to be licensed as a whole at no charge to all third
101
+    parties under the terms of this License.
102
+
103
+    c) If the modified program normally reads commands interactively
104
+    when run, you must cause it, when started running for such
105
+    interactive use in the most ordinary way, to print or display an
106
+    announcement including an appropriate copyright notice and a
107
+    notice that there is no warranty (or else, saying that you provide
108
+    a warranty) and that users may redistribute the program under
109
+    these conditions, and telling the user how to view a copy of this
110
+    License.  (Exception: if the Program itself is interactive but
111
+    does not normally print such an announcement, your work based on
112
+    the Program is not required to print an announcement.)
113
+
114
+These requirements apply to the modified work as a whole.  If
115
+identifiable sections of that work are not derived from the Program,
116
+and can be reasonably considered independent and separate works in
117
+themselves, then this License, and its terms, do not apply to those
118
+sections when you distribute them as separate works.  But when you
119
+distribute the same sections as part of a whole which is a work based
120
+on the Program, the distribution of the whole must be on the terms of
121
+this License, whose permissions for other licensees extend to the
122
+entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+Thus, it is not the intent of this section to claim rights or contest
125
+your rights to work written entirely by you; rather, the intent is to
126
+exercise the right to control the distribution of derivative or
127
+collective works based on the Program.
128
+
129
+In addition, mere aggregation of another work not based on the Program
130
+with the Program (or with a work based on the Program) on a volume of
131
+a storage or distribution medium does not bring the other work under
132
+the scope of this License.
133
+
134
+  3. You may copy and distribute the Program (or a work based on it,
135
+under Section 2) in object code or executable form under the terms of
136
+Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+    a) Accompany it with the complete corresponding machine-readable
139
+    source code, which must be distributed under the terms of Sections
140
+    1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+    b) Accompany it with a written offer, valid for at least three
143
+    years, to give any third party, for a charge no more than your
144
+    cost of physically performing source distribution, a complete
145
+    machine-readable copy of the corresponding source code, to be
146
+    distributed under the terms of Sections 1 and 2 above on a medium
147
+    customarily used for software interchange; or,
148
+
149
+    c) Accompany it with the information you received as to the offer
150
+    to distribute corresponding source code.  (This alternative is
151
+    allowed only for noncommercial distribution and only if you
152
+    received the program in object code or executable form with such
153
+    an offer, in accord with Subsection b above.)
154
+
155
+The source code for a work means the preferred form of the work for
156
+making modifications to it.  For an executable work, complete source
157
+code means all the source code for all modules it contains, plus any
158
+associated interface definition files, plus the scripts used to
159
+control compilation and installation of the executable.  However, as a
160
+special exception, the source code distributed need not include
161
+anything that is normally distributed (in either source or binary
162
+form) with the major components (compiler, kernel, and so on) of the
163
+operating system on which the executable runs, unless that component
164
+itself accompanies the executable.
165
+
166
+If distribution of executable or object code is made by offering
167
+access to copy from a designated place, then offering equivalent
168
+access to copy the source code from the same place counts as
169
+distribution of the source code, even though third parties are not
170
+compelled to copy the source along with the object code.
171
+
172
+  4. You may not copy, modify, sublicense, or distribute the Program
173
+except as expressly provided under this License.  Any attempt
174
+otherwise to copy, modify, sublicense or distribute the Program is
175
+void, and will automatically terminate your rights under this License.
176
+However, parties who have received copies, or rights, from you under
177
+this License will not have their licenses terminated so long as such
178
+parties remain in full compliance.
179
+
180
+  5. You are not required to accept this License, since you have not
181
+signed it.  However, nothing else grants you permission to modify or
182
+distribute the Program or its derivative works.  These actions are
183
+prohibited by law if you do not accept this License.  Therefore, by
184
+modifying or distributing the Program (or any work based on the
185
+Program), you indicate your acceptance of this License to do so, and
186
+all its terms and conditions for copying, distributing or modifying
187
+the Program or works based on it.
188
+
189
+  6. Each time you redistribute the Program (or any work based on the
190
+Program), the recipient automatically receives a license from the
191
+original licensor to copy, distribute or modify the Program subject to
192
+these terms and conditions.  You may not impose any further
193
+restrictions on the recipients' exercise of the rights granted herein.
194
+You are not responsible for enforcing compliance by third parties to
195
+this License.
196
+
197
+  7. If, as a consequence of a court judgment or allegation of patent
198
+infringement or for any other reason (not limited to patent issues),
199
+conditions are imposed on you (whether by court order, agreement or
200
+otherwise) that contradict the conditions of this License, they do not
201
+excuse you from the conditions of this License.  If you cannot
202
+distribute so as to satisfy simultaneously your obligations under this
203
+License and any other pertinent obligations, then as a consequence you
204
+may not distribute the Program at all.  For example, if a patent
205
+license would not permit royalty-free redistribution of the Program by
206
+all those who receive copies directly or indirectly through you, then
207
+the only way you could satisfy both it and this License would be to
208
+refrain entirely from distribution of the Program.
209
+
210
+If any portion of this section is held invalid or unenforceable under
211
+any particular circumstance, the balance of the section is intended to
212
+apply and the section as a whole is intended to apply in other
213
+circumstances.
214
+
215
+It is not the purpose of this section to induce you to infringe any
216
+patents or other property right claims or to contest validity of any
217
+such claims; this section has the sole purpose of protecting the
218
+integrity of the free software distribution system, which is
219
+implemented by public license practices.  Many people have made
220
+generous contributions to the wide range of software distributed
221
+through that system in reliance on consistent application of that
222
+system; it is up to the author/donor to decide if he or she is willing
223
+to distribute software through any other system and a licensee cannot
224
+impose that choice.
225
+
226
+This section is intended to make thoroughly clear what is believed to
227
+be a consequence of the rest of this License.
228
+
229
+  8. If the distribution and/or use of the Program is restricted in
230
+certain countries either by patents or by copyrighted interfaces, the
231
+original copyright holder who places the Program under this License
232
+may add an explicit geographical distribution limitation excluding
233
+those countries, so that distribution is permitted only in or among
234
+countries not thus excluded.  In such case, this License incorporates
235
+the limitation as if written in the body of this License.
236
+
237
+  9. The Free Software Foundation may publish revised and/or new versions
238
+of the General Public License from time to time.  Such new versions will
239
+be similar in spirit to the present version, but may differ in detail to
240
+address new problems or concerns.
241
+
242
+Each version is given a distinguishing version number.  If the Program
243
+specifies a version number of this License which applies to it and "any
244
+later version", you have the option of following the terms and conditions
245
+either of that version or of any later version published by the Free
246
+Software Foundation.  If the Program does not specify a version number of
247
+this License, you may choose any version ever published by the Free Software
248
+Foundation.
249
+
250
+  10. If you wish to incorporate parts of the Program into other free
251
+programs whose distribution conditions are different, write to the author
252
+to ask for permission.  For software which is copyrighted by the Free
253
+Software Foundation, write to the Free Software Foundation; we sometimes
254
+make exceptions for this.  Our decision will be guided by the two goals
255
+of preserving the free status of all derivatives of our free software and
256
+of promoting the sharing and reuse of software generally.
257
+
258
+			    NO WARRANTY
259
+
260
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+REPAIR OR CORRECTION.
269
+
270
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+POSSIBILITY OF SUCH DAMAGES.
279
+
280
+		     END OF TERMS AND CONDITIONS

+ 226
- 0
INSTALL View File

@@ -0,0 +1,226 @@
1
+Basic Installation
2
+==================
3
+
4
+   These are generic installation instructions.
5
+
6
+   The `configure' shell script attempts to guess correct values for
7
+various system-dependent variables used during compilation.  It uses
8
+those values to create a `Makefile' in each directory of the package.
9
+It may also create one or more `.h' files containing system-dependent
10
+definitions.  Finally, it creates a shell script `config.status' that
11
+you can run in the future to recreate the current configuration, and a
12
+file `config.log' containing compiler output (useful mainly for
13
+debugging `configure').
14
+
15
+   It can also use an optional file (typically called `config.cache'
16
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
17
+the results of its tests to speed up reconfiguring.  (Caching is
18
+disabled by default to prevent problems with accidental use of stale
19
+cache files.)
20
+
21
+   If you need to do unusual things to compile the package, please try
22
+to figure out how `configure' could check whether to do them, and mail
23
+diffs or instructions to the address given in the `README' so they can
24
+be considered for the next release.  If you are using the cache, and at
25
+some point `config.cache' contains results you don't want to keep, you
26
+may remove or edit it.
27
+
28
+   The file `configure.ac' (or `configure.in') is used to create
29
+`configure' by a program called `autoconf'.  You only need
30
+`configure.ac' if you want to change it or regenerate `configure' using
31
+a newer version of `autoconf'.
32
+
33
+The simplest way to compile this package is:
34
+
35
+  1. `cd' to the directory containing the package's source code and type
36
+     `./configure' to configure the package for your system.  If you're
37
+     using `csh' on an old version of System V, you might need to type
38
+     `sh ./configure' instead to prevent `csh' from trying to execute
39
+     `configure' itself.
40
+
41
+     Running `configure' takes awhile.  While running, it prints some
42
+     messages telling which features it is checking for.
43
+
44
+  2. Type `make' to compile the package.
45
+
46
+  3. Optionally, type `make check' to run any self-tests that come with
47
+     the package.
48
+
49
+  4. Type `make install' to install the programs and any data files and
50
+     documentation.
51
+
52
+  5. You can remove the program binaries and object files from the
53
+     source code directory by typing `make clean'.  To also remove the
54
+     files that `configure' created (so you can compile the package for
55
+     a different kind of computer), type `make distclean'.  There is
56
+     also a `make maintainer-clean' target, but that is intended mainly
57
+     for the package's developers.  If you use it, you may have to get
58
+     all sorts of other programs in order to regenerate files that came
59
+     with the distribution.
60
+
61
+Compilers and Options
62
+=====================
63
+
64
+   Some systems require unusual options for compilation or linking that
65
+the `configure' script does not know about.  Run `./configure --help'
66
+for details on some of the pertinent environment variables.
67
+
68
+   You can give `configure' initial values for variables by setting
69
+them in the environment.  You can do that on the command line like this:
70
+
71
+     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
72
+
73
+   *Note Environment Variables::, for more details.
74
+
75
+Compiling For Multiple Architectures
76
+====================================
77
+
78
+   You can compile the package for more than one kind of computer at the
79
+same time, by placing the object files for each architecture in their
80
+own directory.  To do this, you must use a version of `make' that
81
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
82
+directory where you want the object files and executables to go and run
83
+the `configure' script.  `configure' automatically checks for the
84
+source code in the directory that `configure' is in and in `..'.
85
+
86
+   If you have to use a `make' that does not support the `VPATH'
87
+variable, you have to compile the package for one architecture at a time
88
+in the source code directory.  After you have installed the package for
89
+one architecture, use `make distclean' before reconfiguring for another
90
+architecture.
91
+
92
+Installation Names
93
+==================
94
+
95
+   By default, `make install' will install the package's files in
96
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
97
+installation prefix other than `/usr/local' by giving `configure' the
98
+option `--prefix=PATH'.
99
+
100
+   You can specify separate installation prefixes for
101
+architecture-specific files and architecture-independent files.  If you
102
+give `configure' the option `--exec-prefix=PATH', the package will use
103
+PATH as the prefix for installing programs and libraries.
104
+Documentation and other data files will still use the regular prefix.
105
+
106
+   In addition, if you use an unusual directory layout you can give
107
+options like `--bindir=PATH' to specify different values for particular
108
+kinds of files.  Run `configure --help' for a list of the directories
109
+you can set and what kinds of files go in them.
110
+
111
+   If the package supports it, you can cause programs to be installed
112
+with an extra prefix or suffix on their names by giving `configure' the
113
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
114
+
115
+Optional Features
116
+=================
117
+
118
+   Some packages pay attention to `--enable-FEATURE' options to
119
+`configure', where FEATURE indicates an optional part of the package.
120
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
121
+is something like `gnu-as' or `x' (for the X Window System).  The
122
+`README' should mention any `--enable-' and `--with-' options that the
123
+package recognizes.
124
+
125
+   For packages that use the X Window System, `configure' can usually
126
+find the X include and library files automatically, but if it doesn't,
127
+you can use the `configure' options `--x-includes=DIR' and
128
+`--x-libraries=DIR' to specify their locations.
129
+
130
+Specifying the System Type
131
+==========================
132
+
133
+   There may be some features `configure' cannot figure out
134
+automatically, but needs to determine by the type of host the package
135
+will run on.  Usually `configure' can figure that out, but if it prints
136
+a message saying it cannot guess the host type, give it the
137
+`--build=TYPE' option.  TYPE can either be a short name for the system
138
+type, such as `sun4', or a canonical name which has the form:
139
+
140
+     CPU-COMPANY-SYSTEM
141
+
142
+where SYSTEM can have one of these forms:
143
+
144
+     OS
145
+     KERNEL-OS
146
+
147
+   See the file `config.sub' for the possible values of each field.  If
148
+`config.sub' isn't included in this package, then this package doesn't
149
+need to know the host type.
150
+
151
+   If you are _building_ compiler tools for cross-compiling, you should
152
+use the `--target=TYPE' option to select the type of system they will
153
+produce code for.
154
+
155
+   If you want to _use_ a cross compiler, that generates code for a
156
+platform different from the build platform, you should specify the host
157
+platform (i.e., that on which the generated programs will eventually be
158
+run) with `--host=TYPE'.  In this case, you should also specify the
159
+build platform with `--build=TYPE', because, in this case, it may not
160
+be possible to guess the build platform (it sometimes involves
161
+compiling and running simple test programs, and this can't be done if
162
+the compiler is a cross compiler).
163
+
164
+Sharing Defaults
165
+================
166
+
167
+   If you want to set default values for `configure' scripts to share,
168
+you can create a site shell script called `config.site' that gives
169
+default values for variables like `CC', `cache_file', and `prefix'.
170
+`configure' looks for `PREFIX/share/config.site' if it exists, then
171
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
172
+`CONFIG_SITE' environment variable to the location of the site script.
173
+A warning: not all `configure' scripts look for a site script.
174
+
175
+Environment Variables
176
+=====================
177
+
178
+   Variables not defined in a site shell script can be set in the
179
+environment passed to configure.  However, some packages may run
180
+configure again during the build, and the customized values of these
181
+variables may be lost.  In order to avoid this problem, you should set
182
+them in the `configure' command line, using `VAR=value'.  For example:
183
+
184
+     ./configure CC=/usr/local2/bin/gcc
185
+
186
+will cause the specified gcc to be used as the C compiler (unless it is
187
+overridden in the site shell script).
188
+
189
+`configure' Invocation
190
+======================
191
+
192
+   `configure' recognizes the following options to control how it
193
+operates.
194
+
195
+`--help'
196
+`-h'
197
+     Print a summary of the options to `configure', and exit.
198
+
199
+`--version'
200
+`-V'
201
+     Print the version of Autoconf used to generate the `configure'
202
+     script, and exit.
203
+
204
+`--cache-file=FILE'
205
+     Enable the cache: use and save the results of the tests in FILE,
206
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
207
+     disable caching.
208
+
209
+`--config-cache'
210
+`-C'
211
+     Alias for `--cache-file=config.cache'.
212
+
213
+`--quiet'
214
+`--silent'
215
+`-q'
216
+     Do not print messages saying which checks are being made.  To
217
+     suppress all normal output, redirect it to `/dev/null' (any error
218
+     messages will still be shown).
219
+
220
+`--srcdir=DIR'
221
+     Look for the package's source code in directory DIR.  Usually
222
+     `configure' can determine that directory automatically.
223
+
224
+`configure' also accepts some other, not widely useful, options.  Run
225
+`configure --help' for more details.
226
+

+ 12
- 0
Makefile.in View File

@@ -0,0 +1,12 @@
1
+# Makefile
2
+# $Id: Makefile.in,v 1.1 2003/04/15 04:03:56 hampa Exp $
3
+
4
+srcdir := @srcdir@
5
+topdir := @top_srcdir@
6
+subdir := src
7
+reldir := .
8
+
9
+include $(reldir)/Makefile.inc
10
+
11
+
12
+all:

+ 91
- 0
Makefile.inc.in View File

@@ -0,0 +1,91 @@
1
+# Makefile include file
2
+# $Id: Makefile.inc.in,v 1.1 2003/04/15 04:03:56 hampa Exp $
3
+
4
+#--------------------------------------------------------------------------
5
+# user editable section
6
+
7
+prefix  	= @prefix@
8
+exec_prefix	= @exec_prefix@
9
+bindir		= @bindir@
10
+libdir		= @libdir@
11
+incdir		= @includedir@
12
+datdir		= @datadir@
13
+
14
+
15
+# Executables
16
+
17
+CC		= @CC@
18
+CFLAGS		= @CFLAGS@
19
+CC_FLG		= $(CFLAGS) -I$(topdir)/src -I$(reldir)/src
20
+
21
+NASM		= @NASM@
22
+
23
+LD              = @CC@
24
+LDFLAGS		= @LDFLAGS@
25
+LD_FLG          = $(LDFLAGS)
26
+
27
+AR		= @AR@
28
+AR_FLG		= -rs
29
+
30
+LN_S		= @LN_S@
31
+LN_S_FLG	= -f
32
+
33
+INSTALL		= @INSTALL@
34
+INSTALL_FLG	=
35
+
36
+@SET_MAKE@
37
+MAKE_FLG	=
38
+
39
+
40
+# end of user editable section
41
+#--------------------------------------------------------------------------
42
+
43
+PCE_VERSION_MAJ := @PCE_VERSION_MAJ@
44
+PCE_VERSION_MIN := @PCE_VERSION_MIN@
45
+PCE_VERSION_MIC := @PCE_VERSION_MIC@
46
+PCE_VERSION_STR := @PCE_VERSION_STR@
47
+
48
+
49
+VPATH = $(srcdir)
50
+
51
+
52
+ifneq "$(dstdir)" "$(topdir)"
53
+CC_FLG	+= -I$(topdir)/src
54
+endif
55
+
56
+
57
+all: subdirs
58
+
59
+
60
+subdirs: subdirs-rec
61
+subdirs-rec:
62
+ifneq "$(subdir)" ""
63
+	@for dir in $(subdir); do \
64
+		(cd $$dir && $(MAKE) $(MAKE_FLG)); \
65
+	done
66
+endif
67
+
68
+
69
+clean: clean-rec
70
+clean-rec:
71
+ifneq "$(subdir)" ""
72
+	@for dir in $(subdir); do \
73
+		(cd $$dir && $(MAKE) $(MAKE_FLG) clean); \
74
+	done
75
+endif
76
+
77
+
78
+install: install-rec
79
+install-rec:
80
+ifneq "$(subdir)" ""
81
+	@for dir in $(subdir); do \
82
+		(cd $$dir && $(MAKE) $(MAKE_FLG) install); \
83
+	done
84
+endif
85
+
86
+
87
+%.o: %.c
88
+	$(CC) -c $(CC_FLG) -o $@ $<
89
+
90
+%.bin: %.asm
91
+	$(NASM) -f bin -l $*.lst -o $@ $<

+ 3
- 0
NEWS View File

@@ -0,0 +1,3 @@
1
+0.0.2
2
+
3
+0.0.1	2001-05-02

+ 0
- 0
README View File


+ 0
- 0
TODO View File


+ 100
- 0
configure.in View File

@@ -0,0 +1,100 @@
1
+#*****************************************************************************
2
+#* pce                                                                       *
3
+#*****************************************************************************
4
+
5
+#*****************************************************************************
6
+#* File name:     configure.in                                               *
7
+#* Created:       2002-05-20 by Hampa Hug <hampa@hampa.ch>                   *
8
+#* Last modified: 2003-04-15 by Hampa Hug <hampa@hampa.ch>                   *
9
+#* Copyright:     (C) 2002-2003 by Hampa Hug <hampa@hampa.ch>                *
10
+#*****************************************************************************
11
+
12
+#*****************************************************************************
13
+#* This program is free software. You can redistribute it and / or modify it *
14
+#* under the terms of the GNU General Public License version 2 as  published *
15
+#* by the Free Software Foundation.                                          *
16
+#*                                                                           *
17
+#* This program is distributed in the hope  that  it  will  be  useful,  but *
18
+#* WITHOUT  ANY   WARRANTY,   without   even   the   implied   warranty   of *
19
+#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  General *
20
+#* Public License for more details.                                          *
21
+#*****************************************************************************
22
+
23
+# $Id: configure.in,v 1.1 2003/04/15 04:03:56 hampa Exp $
24
+
25
+
26
+AC_INIT(Makefile.in)
27
+AC_CONFIG_HEADER(src/config.h)
28
+
29
+
30
+dnl -----------------------------------------------------------------------
31
+
32
+AC_MSG_CHECKING([pce version])
33
+PCE_VERSION_MAJ=0
34
+PCE_VERSION_MIN=0
35
+PCE_VERSION_MIC=3
36
+PCE_VERSION_STR="$PCE_VERSION_MAJ.$PCE_VERSION_MIN.$PCE_VERSION_MIC"
37
+AC_SUBST($PCE_VERSION_MAJ)
38
+AC_SUBST($PCE_VERSION_MIN)
39
+AC_SUBST($PCE_VERSION_MIC)
40
+AC_SUBST($PCE_VERSION_STR)
41
+AC_DEFINE_UNQUOTED(PCE_VERSION_MAJ, $PCE_VERSION_MAJ)
42
+AC_DEFINE_UNQUOTED(PCE_VERSION_MIN, $PCE_VERSION_MIN)
43
+AC_DEFINE_UNQUOTED(PCE_VERSION_MIC, $PCE_VERSION_MIC)
44
+AC_DEFINE_UNQUOTED(PCE_VERSION_STR, "$PCE_VERSION_STR")
45
+AC_MSG_RESULT($PCE_VERSION_STR)
46
+
47
+
48
+dnl -----------------------------------------------------------------------
49
+dnl Checks for programs.
50
+
51
+AC_PROG_CC
52
+AC_PROG_INSTALL
53
+AC_PATH_PROG(AR, ar, ar)
54
+AC_PATH_PROG(NASM, nasm, nasm)
55
+AC_PROG_MAKE_SET
56
+AC_PROG_LN_S
57
+
58
+
59
+dnl -----------------------------------------------------------------------
60
+dnl Checks for header files.
61
+
62
+AC_HEADER_STDC
63
+AC_CHECK_HEADERS(limits.h unistd.h fcntl.h)
64
+
65
+
66
+dnl -----------------------------------------------------------------------
67
+dnl Checks for libraries
68
+
69
+
70
+AC_OUTPUT(
71
+  Makefile.inc
72
+  Makefile
73
+  src/Makefile
74
+  src/bios/Makefile
75
+  src/e8086/Makefile
76
+)
77
+
78
+
79
+dnl -----------------------------------------------------------------------
80
+
81
+eval "pce_bindir=$bindir"
82
+eval "pce_bindir=$pce_bindir"
83
+
84
+eval "pce_libdir=$libdir"
85
+eval "pce_libdir=$pce_libdir"
86
+
87
+eval "pce_mandir=$mandir"
88
+eval "pce_mandir=$pce_mandir"
89
+
90
+echo ""
91
+echo "pce $PCE_VERSION_STR is now configured:"
92
+
93
+echo "  CC:                    $CC"
94
+echo "  CFLAGS:                \"$CFLAGS\""
95
+echo "  LDFLAGS:               \"$LDFLAGS\""
96
+echo ""
97
+echo "  prefix:                $prefix"
98
+echo "  bindir:                $pce_bindir"
99
+echo "  libdir:                $pce_libdir"
100
+echo "  mandir:                $pce_mandir"

+ 250
- 0
install-sh View File

@@ -0,0 +1,250 @@
1
+#!/bin/sh
2
+#
3
+# install - install a program, script, or datafile
4
+# This comes from X11R5 (mit/util/scripts/install.sh).
5
+#
6
+# Copyright 1991 by the Massachusetts Institute of Technology
7
+#
8
+# Permission to use, copy, modify, distribute, and sell this software and its
9
+# documentation for any purpose is hereby granted without fee, provided that
10
+# the above copyright notice appear in all copies and that both that
11
+# copyright notice and this permission notice appear in supporting
12
+# documentation, and that the name of M.I.T. not be used in advertising or
13
+# publicity pertaining to distribution of the software without specific,
14
+# written prior permission.  M.I.T. makes no representations about the
15
+# suitability of this software for any purpose.  It is provided "as is"
16
+# without express or implied warranty.
17
+#
18
+# Calling this script install-sh is preferred over install.sh, to prevent
19
+# `make' implicit rules from creating a file called install from it
20
+# when there is no Makefile.
21
+#
22
+# This script is compatible with the BSD install script, but was written
23
+# from scratch.  It can only install one file at a time, a restriction
24
+# shared with many OS's install programs.
25
+
26
+
27
+# set DOITPROG to echo to test this script
28
+
29
+# Don't use :- since 4.3BSD and earlier shells don't like it.
30
+doit="${DOITPROG-}"
31
+
32
+
33
+# put in absolute paths if you don't have them in your path; or use env. vars.
34
+
35
+mvprog="${MVPROG-mv}"
36
+cpprog="${CPPROG-cp}"
37
+chmodprog="${CHMODPROG-chmod}"
38
+chownprog="${CHOWNPROG-chown}"
39
+chgrpprog="${CHGRPPROG-chgrp}"
40
+stripprog="${STRIPPROG-strip}"
41
+rmprog="${RMPROG-rm}"
42
+mkdirprog="${MKDIRPROG-mkdir}"
43
+
44
+transformbasename=""
45
+transform_arg=""
46
+instcmd="$mvprog"
47
+chmodcmd="$chmodprog 0755"
48
+chowncmd=""
49
+chgrpcmd=""
50
+stripcmd=""
51
+rmcmd="$rmprog -f"
52
+mvcmd="$mvprog"
53
+src=""
54
+dst=""
55
+dir_arg=""
56
+
57
+while [ x"$1" != x ]; do
58
+    case $1 in
59
+	-c) instcmd="$cpprog"
60
+	    shift
61
+	    continue;;
62
+
63
+	-d) dir_arg=true
64
+	    shift
65
+	    continue;;
66
+
67
+	-m) chmodcmd="$chmodprog $2"
68
+	    shift
69
+	    shift
70
+	    continue;;
71
+
72
+	-o) chowncmd="$chownprog $2"
73
+	    shift
74
+	    shift
75
+	    continue;;
76
+
77
+	-g) chgrpcmd="$chgrpprog $2"
78
+	    shift
79
+	    shift
80
+	    continue;;
81
+
82
+	-s) stripcmd="$stripprog"
83
+	    shift
84
+	    continue;;
85
+
86
+	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
87
+	    shift
88
+	    continue;;
89
+
90
+	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
91
+	    shift
92
+	    continue;;
93
+
94
+	*)  if [ x"$src" = x ]
95
+	    then
96
+		src=$1
97
+	    else
98
+		# this colon is to work around a 386BSD /bin/sh bug
99
+		:
100
+		dst=$1
101
+	    fi
102
+	    shift
103
+	    continue;;
104
+    esac
105
+done
106
+
107
+if [ x"$src" = x ]
108
+then
109
+	echo "install:	no input file specified"
110
+	exit 1
111
+else
112
+	true
113
+fi
114
+
115
+if [ x"$dir_arg" != x ]; then
116
+	dst=$src
117
+	src=""
118
+	
119
+	if [ -d $dst ]; then
120
+		instcmd=:
121
+	else
122
+		instcmd=mkdir
123
+	fi
124
+else
125
+
126
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
127
+# might cause directories to be created, which would be especially bad 
128
+# if $src (and thus $dsttmp) contains '*'.
129
+
130
+	if [ -f $src -o -d $src ]
131
+	then
132
+		true
133
+	else
134
+		echo "install:  $src does not exist"
135
+		exit 1
136
+	fi
137
+	
138
+	if [ x"$dst" = x ]
139
+	then
140
+		echo "install:	no destination specified"
141
+		exit 1
142
+	else
143
+		true
144
+	fi
145
+
146
+# If destination is a directory, append the input filename; if your system
147
+# does not like double slashes in filenames, you may need to add some logic
148
+
149
+	if [ -d $dst ]
150
+	then
151
+		dst="$dst"/`basename $src`
152
+	else
153
+		true
154
+	fi
155
+fi
156
+
157
+## this sed command emulates the dirname command
158
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
159
+
160
+# Make sure that the destination directory exists.
161
+#  this part is taken from Noah Friedman's mkinstalldirs script
162
+
163
+# Skip lots of stat calls in the usual case.
164
+if [ ! -d "$dstdir" ]; then
165
+defaultIFS='	
166
+'
167
+IFS="${IFS-${defaultIFS}}"
168
+
169
+oIFS="${IFS}"
170
+# Some sh's can't handle IFS=/ for some reason.
171
+IFS='%'
172
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
173
+IFS="${oIFS}"
174
+
175
+pathcomp=''
176
+
177
+while [ $# -ne 0 ] ; do
178
+	pathcomp="${pathcomp}${1}"
179
+	shift
180
+
181
+	if [ ! -d "${pathcomp}" ] ;
182
+        then
183
+		$mkdirprog "${pathcomp}"
184
+	else
185
+		true
186
+	fi
187
+
188
+	pathcomp="${pathcomp}/"
189
+done
190
+fi
191
+
192
+if [ x"$dir_arg" != x ]
193
+then
194
+	$doit $instcmd $dst &&
195
+
196
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
197
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
198
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
199
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
200
+else
201
+
202
+# If we're going to rename the final executable, determine the name now.
203
+
204
+	if [ x"$transformarg" = x ] 
205
+	then
206
+		dstfile=`basename $dst`
207
+	else
208
+		dstfile=`basename $dst $transformbasename | 
209
+			sed $transformarg`$transformbasename
210
+	fi
211
+
212
+# don't allow the sed command to completely eliminate the filename
213
+
214
+	if [ x"$dstfile" = x ] 
215
+	then
216
+		dstfile=`basename $dst`
217
+	else
218
+		true
219
+	fi
220
+
221
+# Make a temp file name in the proper directory.
222
+
223
+	dsttmp=$dstdir/#inst.$$#
224
+
225
+# Move or copy the file name to the temp name
226
+
227
+	$doit $instcmd $src $dsttmp &&
228
+
229
+	trap "rm -f ${dsttmp}" 0 &&
230
+
231
+# and set any options; do chmod last to preserve setuid bits
232
+
233
+# If any of these fail, we abort the whole thing.  If we want to
234
+# ignore errors from any of these, just make sure not to ignore
235
+# errors from the above "$doit $instcmd $src $dsttmp" command.
236
+
237
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
238
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
239
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
240
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
241
+
242
+# Now rename the file to the real destination.
243
+
244
+	$doit $rmcmd -f $dstdir/$dstfile &&
245
+	$doit $mvcmd $dsttmp $dstdir/$dstfile 
246
+
247
+fi &&
248
+
249
+
250
+exit 0

+ 14
- 0
pce.lsm View File

@@ -0,0 +1,14 @@
1
+Begin4
2
+Title:		PCE
3
+Version:	0.0.3
4
+Entered-date:	2003-04-15
5
+Description:	PC Emulator
6
+Keywords:	PC emulator
7
+Author: 	Hampa Hug <hampa@hampa.ch>
8
+Maintained-by:	Hampa Hug <hampa@hampa.ch>
9
+Primary-site:	
10
+Alternate-site:	
11
+Original-site:	
12
+Platforms:	Linux, Unix
13
+Copying-policy:	GPL
14
+End

+ 56
- 0
src/Makefile.in View File

@@ -0,0 +1,56 @@
1
+# Makefile
2
+# $Id: Makefile.in,v 1.1 2003/04/15 04:03:56 hampa Exp $
3
+
4
+srcdir := @srcdir@
5
+topdir := @top_srcdir@
6
+subdir := e8086 bios
7
+reldir := ..
8
+
9
+include $(reldir)/Makefile.inc
10
+
11
+
12
+SRC	:= floppy.c ibmpc.c keyboard.c mda.c memory.c pce.c
13
+
14
+OBJ	:= floppy.o ibmpc.o keyboard.o mda.o memory.o pce.o
15
+OBJ_EXT	:= e8086/e8086.a
16
+
17
+HDR	:= floppy.h ibmpc.h keyboard.h mda.h memory.h pce.h
18
+HDR_EXT	:=
19
+
20
+MAN	:=
21
+
22
+BIN	:= pce
23
+
24
+SDP	:= Makefile $(HDR) $(HDR_EXT)
25
+BDP	:= Makefile $(OBJ) $(OBJ_EXT)
26
+
27
+
28
+all: $(BIN) $(OBJ)
29
+
30
+
31
+clean:
32
+	rm -f $(OBJ) $(BIN)
33
+
34
+
35
+install:
36
+	$(INSTALL) -d -m 755 $(bindir)
37
+	$(INSTALL) -m 755 -s $(BIN) $(bindir)
38
+ifneq "$(MAN)" ""
39
+	$(INSTALL) -d -m 755 $(mandir)/man1
40
+	for f in $(MAN) ; do \
41
+		rm -f $(mandir)/man1/$$f.gz ; \
42
+		gzip -c --best $(srcdir)/$$f > $(mandir)/man1/$$f.gz ; \
43
+	done
44
+endif
45
+
46
+
47
+pce: $(OBJ) $(OBJ_EXT)
48
+	$(LD) $(LD_FLG) -o $@ $(OBJ) $(OBJ_EXT)
49
+
50
+
51
+floppy.o:	floppy.c $(SDP)
52
+ibmpc.o:	ibmpc.c $(SDP)
53
+keyboard.o:	keyboard.c $(SDP)
54
+mda.o:		mda.c $(SDP)
55
+memory.o:	memory.c $(SDP)
56
+pce.o:		pce.c $(SDP)

+ 45
- 0
src/bios/Makefile.in View File

@@ -0,0 +1,45 @@
1
+# Makefile
2
+# $Id: Makefile.in,v 1.1 2003/04/15 04:03:56 hampa Exp $
3
+
4
+srcdir := @srcdir@
5
+topdir := @top_srcdir@
6
+subdir :=
7
+reldir := ../..
8
+
9
+include $(reldir)/Makefile.inc
10
+
11
+
12
+SRC	:= basic.asm bios.asm pce.asm
13
+
14
+OBJ	:= basic.bin bios.bin pce.bin
15
+OBJ_EXT	:=
16
+
17
+HDR	:=
18
+HDR_EXT	:=
19
+
20
+MAN	:=
21
+
22
+BIN	:= ibmpc.rom
23
+
24
+SDP	:= Makefile $(HDR) $(HDR_EXT)
25
+BDP	:= Makefile $(OBJ) $(OBJ_EXT)
26
+
27
+
28
+all: $(BIN)
29
+
30
+
31
+clean:
32
+	rm -f $(OBJ) $(BIN)
33
+
34
+
35
+cmp:
36
+	fcmp $(topdir)/contrib/bios/ibmpc.cmp ibmpc.rom > ibmpc.diff
37
+
38
+
39
+ibmpc.rom: $(OBJ)
40
+	cat pce.bin basic.bin bios.bin > $@
41
+
42
+
43
+pce.bin:	pce.asm
44
+bios.bin:	bios.asm
45
+basic.bin:	basic.asm

+ 15596
- 0
src/bios/basic.asm
File diff suppressed because it is too large
View File


+ 4738
- 0
src/bios/bios.asm
File diff suppressed because it is too large
View File


+ 195
- 0
src/bios/pce.asm View File

@@ -0,0 +1,195 @@
1
+; BIOS
2
+
3
+%macro set_pos 1
4
+  times %1 - ($ - $$) db 0
5
+%endmacro
6
+
7
+SECTION .text
8
+
9
+;-----------------------------------------------------------------------------
10
+
11
+start:
12
+  mov     ax, 0x0050
13
+  mov     ss, ax
14
+  mov     sp, 1024
15
+
16
+  call    set_bios_ds
17
+
18
+  call    init_int
19
+  call    init_misc
20
+  call    init_keyboard
21
+
22
+  mov     ax, 0x0007
23
+  int     0x10
24
+
25
+  push    cs
26
+  pop     ds
27
+
28
+  mov     si, msg_init
29
+  call    prt_string
30
+
31
+  int     0x19
32
+
33
+done:
34
+  jmp     done
35
+
36
+
37
+testdiv   dw 13
38
+
39
+msg_init:
40
+  db      "PC BIOS", 13, 10
41
+  db      "(hacked up version for PCE)", 13, 10, 0
42
+
43
+
44
+;-----------------------------------------------------------------------------
45
+
46
+init_int:
47
+  push    ax
48
+  push    cx
49
+  push    si
50
+  push    di
51
+  push    es
52
+  push    ds
53
+
54
+  mov     ax, 0xf000
55
+  mov     ds, ax
56
+  mov     si, inttab
57
+
58
+  xor     di, di
59
+  mov     es, di
60
+
61
+  mov     cx, 32 * 2
62
+  cld
63
+  rep     movsw
64
+
65
+  mov     cx, 256 - 32
66
+
67
+.next:
68
+  mov     ax, int_default
69
+  stosw
70
+  mov     ax, 0xf000
71
+  stosw
72
+  loop    .next
73
+
74
+  pop     ds
75
+  pop     es
76
+  pop     di
77
+  pop     si
78
+  pop     cx
79
+  pop     ax
80
+  ret
81
+
82
+
83
+init_misc:
84
+  mov     [0x0010], word 0x0031         ; equipment word
85
+  mov     [0x0013], word 512            ; ram size
86
+
87
+  mov     [0x006c], word 0x0000
88
+  mov     [0x006e], word 0x0000
89
+  mov     [0x0070], byte 0x00
90
+
91
+  ret
92
+
93
+
94
+init_keyboard:
95
+  mov     [0x0080], word 0x001e         ; keyboard buffer start
96
+  mov     [0x0082], word 0x003e         ; keyboard buffer end
97
+
98
+  mov     [0x001a], word 0x001e
99
+  mov     [0x001c], word 0x001e
100
+
101
+  ret
102
+
103
+
104
+set_bios_ds:
105
+  mov     ds, [cs:.bios_ds]
106
+  ret
107
+
108
+.bios_ds:
109
+  dw      0x0040
110
+
111
+inttab:
112
+  dw      int_00, 0xf000
113
+  dw      int_default, 0xf000
114
+  dw      int_default, 0xf000
115
+  dw      int_default, 0xf000
116
+  dw      int_default, 0xf000
117
+  dw      int_default, 0xf000
118
+  dw      int_default, 0xf000
119
+  dw      int_default, 0xf000
120
+  dw      int_default, 0xf000
121
+  dw      int_default, 0xf000
122
+  dw      int_default, 0xf000
123
+  dw      int_default, 0xf000
124
+  dw      int_default, 0xf000
125
+  dw      int_default, 0xf000
126
+  dw      int_default, 0xf000
127
+  dw      int_default, 0xf000
128
+  dw      0xf065, 0xf000 ;int_10, 0xf000
129
+  dw      0xf84d, 0xf000 ;int_11, 0xf000
130
+  dw      0xf841, 0xf000 ;int_12, 0xf000
131
+  dw      int_13, 0xf000
132
+  dw      int_default, 0xf000
133
+  dw      int_default, 0xf000
134
+  dw      0xe82e, 0xf000 ;int_16, 0xf000
135
+;  dw      int_16, 0xf000
136
+  dw      int_default, 0xf000
137
+  dw      int_18, 0xf000
138
+  dw      0xe6f2, 0xf000 ;int_19, 0xf000
139
+  dw      0xfe6e, 0xf000 ;int_1a, 0xf000
140
+  dw      int_default, 0xf000
141
+  dw      int_default, 0xf000
142
+  dw      0xf0a4, 0xf000 ;int_1d, 0xf000
143
+  dw      int_default, 0xf000
144
+  dw      int_default, 0xf000
145
+
146
+
147
+int_default:
148
+  iret
149
+
150
+
151
+;-----------------------------------------------------------------------------
152
+
153
+int_00:
154
+  iret
155
+
156
+
157
+;-----------------------------------------------------------------------------
158
+
159
+int_13:
160
+  db      0x66, 0x66, 0xcd, 0x13
161
+  retf    2
162
+
163
+
164
+int_16:
165
+  mov     ax, 0x3062
166
+  or      ax, ax
167
+  retf    2
168
+
169
+int_18:
170
+  jmp     0xf600:0x0000
171
+  iret
172
+
173
+
174
+prt_string:
175
+  push    ax
176
+  push    si
177
+
178
+.next
179
+  lodsb
180
+  or      al, al
181
+  jz      .done
182
+
183
+  mov     ah, 0x0e
184
+  int     0x10
185
+
186
+  jmp     short .next
187
+
188
+.done
189
+  pop     si
190
+  pop     ax
191
+  ret
192
+
193
+;-----------------------------------------------------------------------------
194
+
195
+  set_pos (0x6000)

+ 40
- 0
src/config.h.in View File

@@ -0,0 +1,40 @@
1
+/*****************************************************************************
2
+ * pce                                                                       *
3
+ *****************************************************************************/
4
+
5
+/*****************************************************************************
6
+ * File name:     config.h.in                                                *
7
+ * Created:       2002-12-16 by Hampa Hug <hampa@hampa.ch>                   *
8
+ * Last modified: 2003-02-08 by Hampa Hug <hampa@hampa.ch>                   *
9
+ * Copyright:     (C) 2002-2003 by Hampa Hug <hampa@hampa.ch>                *
10
+ *****************************************************************************/
11
+
12
+/*****************************************************************************
13
+ * This program is free software. You can redistribute it and / or modify it *
14
+ * under the terms of the GNU General Public License version 2 as  published *
15
+ * by the Free Software Foundation.                                          *
16
+ *                                                                           *
17
+ * This program is distributed in the hope  that  it  will  be  useful,  but *
18
+ * WITHOUT  ANY   WARRANTY,   without   even   the   implied   warranty   of *
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  General *
20
+ * Public License for more details.                                          *
21
+ *****************************************************************************/
22
+
23
+/* $Id: config.h.in,v 1.1 2003/04/15 04:03:56 hampa Exp $ */
24
+
25
+
26
+#ifndef PCE_CONFIG_H
27
+#define PCE_CONFIG_H 1
28
+
29
+
30
+#undef HAVE_LIMITS_H
31
+
32
+#undef HAVE_STDINT_H
33
+
34
+#undef PCE_VERSION_MAJ
35
+#undef PCE_VERSION_MIN
36
+#undef PCE_VERSION_MIC
37
+#undef PCE_VERSION_STR
38
+
39
+
40
+#endif

+ 42
- 0
src/e8086/Makefile.in View File

@@ -0,0 +1,42 @@
1
+# Makefile
2
+# $Id: Makefile.in,v 1.1 2003/04/15 04:03:58 hampa Exp $
3
+
4
+srcdir := @srcdir@
5
+topdir := @top_srcdir@
6
+subdir :=
7
+reldir := ../..
8
+
9
+include $(reldir)/Makefile.inc
10
+
11
+
12
+SRC	:= disasm.c e8086.c ea.c microcode.c
13
+
14
+OBJ	:= disasm.o e8086.o ea.o microcode.o
15
+
16
+HDR	:= e8086.h internal.h
17
+HDR_EXT	:=
18
+
19
+MAN	:=
20
+
21
+BIN	:= e8086.a
22
+
23
+SDP	:= Makefile $(HDR) $(HDR_EXT)
24
+BDP	:= Makefile $(OBJ) $(OBJ_EXT)
25
+
26
+
27
+all: $(BIN)
28
+
29
+
30
+clean:
31
+	rm -f $(BIN) $(OBJ)
32
+
33
+
34
+e8086.a: $(OBJ)
35
+	rm -f $@
36
+	$(AR) $(AR_FLG) $@ $(OBJ)
37
+
38
+
39
+disasm.o:	disasm.c $(SDP)
40
+e8086.o:	e8086.c $(SDP)
41
+ea.o:		ea.c $(SDP)
42
+microcode.o:	microcode.c $(SDP)

+ 1844
- 0
src/e8086/disasm.c
File diff suppressed because it is too large
View File


+ 339
- 0
src/e8086/e8086.c View File

@@ -0,0 +1,339 @@
1
+/*****************************************************************************
2
+ * pce                                                                       *
3
+ *****************************************************************************/
4
+
5
+/*****************************************************************************
6
+ * File name:     e8086.c                                                    *
7
+ * Created:       1996-04-28 by Hampa Hug <hampa@hampa.ch>                   *
8
+ * Last modified: 2003-04-14 by Hampa Hug <hampa@hampa.ch>                   *
9
+ * Copyright:     (C) 1996-2003 by Hampa Hug <hampa@hampa.ch>                *
10
+ *****************************************************************************/
11
+
12
+/*****************************************************************************
13
+ * This program is free software. You can redistribute it and / or modify it *
14
+ * under the terms of the GNU General Public License version 2 as  published *
15
+ * by the Free Software Foundation.                                          *
16
+ *                                                                           *
17
+ * This program is distributed in the hope  that  it  will  be  useful,  but *
18
+ * WITHOUT  ANY   WARRANTY,   without   even   the   implied   warranty   of *
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  General *
20
+ * Public License for more details.                                          *
21
+ *****************************************************************************/
22
+
23
+/* $Id: e8086.c,v 1.1 2003/04/15 04:03:58 hampa Exp $ */
24
+
25
+
26
+#include <pce.h>
27
+
28
+#include "e8086.h"
29
+#include "internal.h"
30
+
31
+
32
+/*************************************************************************
33
+ * Prefetch queue functions
34
+ *************************************************************************/
35
+
36
+void e86_pq_init (e8086_t *c)
37
+{
38
+  c->pq_cnt = 0;
39
+}
40
+
41
+void e86_pq_fill (e8086_t *c)
42
+{
43
+  unsigned i, j;
44
+
45
+  j = 0;
46
+
47
+  for (i = c->pq_cnt; i < E86_PQ_SIZE; i++) {
48
+    c->pq[i] = e86_get_mem8 (c, c->sreg[E86_REG_CS], c->ip + i);
49
+  }
50
+}
51
+
52
+void e86_pq_adjust (e8086_t *c, unsigned cnt)
53
+{
54
+  unsigned i;
55
+
56
+  if (cnt >= c->pq_cnt) {
57
+    c->pq_cnt = 0;
58
+    return;
59
+  }
60
+
61
+  for (i = cnt; i < c->pq_cnt; i++) {
62
+    c->pq[i - cnt] = c->pq[i];
63
+  }
64
+
65
+  c->pq_cnt -= cnt;
66
+}
67
+
68
+
69
+/*************************************************************************
70
+ * Flags functions
71
+ *************************************************************************/
72
+
73
+void e86_set_flags8 (e8086_t *c, unsigned short mask, unsigned short dst, unsigned short src)
74
+{
75
+  unsigned short set;
76
+
77
+  set = 0;
78
+
79
+  if (mask & E86_FLG_C) {
80
+    if (dst & 0xff00) {
81
+      set |= E86_FLG_C;
82
+    }
83
+  }
84
+
85
+  if (mask & E86_FLG_Z) {
86
+    if ((dst & 0x00ff) == 0) {
87
+      set |= E86_FLG_Z;
88
+    }
89
+  }
90
+
91
+  if (mask & E86_FLG_S) {
92
+    if (dst & 0x0080) {
93
+      set |= E86_FLG_S;
94
+    }
95
+  }
96
+
97
+  if (mask & E86_FLG_O) {
98
+    if (((src ^ dst) & 0x80) && ((dst & 0xff00) == 0)) {
99
+      set |= E86_FLG_O;
100
+    }
101
+  }
102
+
103
+  if (mask & E86_FLG_P) {
104
+    unsigned i, n;
105
+
106
+    i = dst & 0xff;
107
+    n = 0;
108
+    while (i != 0) {
109
+      n += 1;
110
+      i &= (i - 1);
111
+    }
112
+
113
+    if ((n & 1) == 0) {
114
+      set |= E86_FLG_P;
115
+    }
116
+  }
117
+
118
+  c->flg &= ~mask;
119
+  c->flg |= set;
120
+}
121
+
122
+void e86_set_flags16 (e8086_t *c, unsigned short mask, unsigned long dst, unsigned long src)
123
+{
124
+  unsigned short set;
125
+
126
+  set = 0;
127
+
128
+  if (mask & E86_FLG_C) {
129
+    if (dst & 0xffff0000UL) {
130
+      set |= E86_FLG_C;
131
+    }
132
+  }
133
+
134
+  if (mask & E86_FLG_Z) {
135
+    if ((dst & 0x0000ffffUL) == 0) {
136
+      set |= E86_FLG_Z;
137
+    }
138
+  }
139
+
140
+  if (mask & E86_FLG_S) {
141
+    if (dst & 0x00008000UL) {
142
+      set |= E86_FLG_S;
143
+    }
144
+  }
145
+
146
+  if (mask & E86_FLG_O) {
147
+    if (((src ^ dst) & 0x8000UL) && ((dst & 0xffff0000UL) == 0)) {
148
+      set |= E86_FLG_O;
149
+    }
150
+  }
151
+
152
+  if (mask & E86_FLG_P) {
153
+    unsigned i, n;
154
+
155
+    i = dst & 0xffff;
156
+    n = 0;
157
+    while (i != 0) {
158
+      n += 1;
159
+      i &= (i - 1);
160
+    }
161
+
162
+    if ((n & 1) == 0) {
163
+      set |= E86_FLG_P;
164
+    }
165
+  }
166
+
167
+  c->flg &= ~mask;
168
+  c->flg |= set;
169
+}
170
+
171
+void e86_set_flags_af (e8086_t *c, unsigned d)
172
+{
173
+  if (d & ~0x0f) {
174
+    c->flg |= E86_FLG_A;
175
+  }
176
+  else {
177
+    c->flg &= ~E86_FLG_A;
178
+  }
179
+}
180
+
181
+static
182
+unsigned char e86_get_mem_uint8 (void *mem, unsigned long addr)
183
+{
184
+  return (0xaa);
185
+}
186
+
187
+static
188
+unsigned short e86_get_mem_uint16 (void *mem, unsigned long addr)
189
+{
190
+  return (0xaaaa);
191
+}
192
+
193
+static
194
+void e86_set_mem_uint8 (void *mem, unsigned long addr, unsigned char val)
195
+{
196
+}
197
+
198
+static
199
+void e86_set_mem_uint16 (void *mem, unsigned long addr, unsigned short val)
200
+{
201
+}
202
+
203
+void e86_prt_state (e8086_t *c, FILE *fp)
204
+{
205
+  static char  ft[2] = { '-', '+' };
206
+
207
+  fprintf (fp, "-8086-state------------------------------------------------------------------\n");
208
+  fprintf (fp, "clk=%lu  op=%lu  delay=%lu\n", c->clocks, c->instructions, c->delay);
209
+
210
+  fprintf (fp,
211
+    "AX=%04X  BX=%04X  CX=%04X  DX=%04X  SP=%04X  BP=%04X  SI=%04X  DI=%04X\n",
212
+    c->dreg[E86_REG_AX],
213
+    c->dreg[E86_REG_BX],
214
+    c->dreg[E86_REG_CX],
215
+    c->dreg[E86_REG_DX],
216
+    c->dreg[E86_REG_SP],
217
+    c->dreg[E86_REG_BP],
218
+    c->dreg[E86_REG_SI],
219
+    c->dreg[E86_REG_DI]
220
+  );
221
+
222
+  fprintf (fp, "CS=%04X  DS=%04X  ES=%04X  SS=%04X  IP=%04X  F =%04X",
223
+    c->sreg[E86_REG_CS],
224
+    c->sreg[E86_REG_DS],
225
+    c->sreg[E86_REG_ES],
226
+    c->sreg[E86_REG_SS],
227
+    c->ip,
228
+    c->flg
229
+  );
230
+
231
+  fprintf (fp, "  C%c O%c S%c Z%c A%c P%c I%c D%c\n",
232
+    ft[(c->flg & E86_FLG_C) != 0],
233
+    ft[(c->flg & E86_FLG_O) != 0],
234
+    ft[(c->flg & E86_FLG_S) != 0],
235
+    ft[(c->flg & E86_FLG_Z) != 0],
236
+    ft[(c->flg & E86_FLG_A) != 0],
237
+    ft[(c->flg & E86_FLG_P) != 0],
238
+    ft[(c->flg & E86_FLG_I) != 0],
239
+    ft[(c->flg & E86_FLG_D) != 0]
240
+  );
241
+}
242
+
243
+void e86_execute (e8086_t *c)
244
+{
245
+  unsigned op;
246
+  unsigned cnt;
247
+
248
+  c->prefix = 0;
249
+
250
+  do {
251
+    e86_pq_fill (c);
252
+
253
+    op = c->pq[0];
254
+
255
+    c->prefix &= ~E86_PREFIX_NEW;
256
+
257
+    cnt = e86_opcodes[op] (c);
258
+
259
+    if (cnt == 0) {
260
+      e86_pq_init (c);
261
+    }
262
+    else {
263
+      c->ip = (c->ip + cnt) & 0xffff;
264
+      e86_pq_adjust (c, cnt);
265
+    }
266
+  } while (c->prefix & E86_PREFIX_NEW);
267
+
268
+  c->instructions += 1;
269
+}
270
+
271
+void e86_clock (e8086_t *c)
272
+{
273
+  if (c->delay > 0) {
274
+    c->delay--;
275
+  }
276
+
277
+  if (c->delay == 0) {
278
+    e86_execute (c);
279
+  }
280
+
281
+  c->clocks += 1;
282
+}
283
+
284
+void e86_reset (e8086_t *c)
285
+{
286
+  unsigned i;
287
+
288
+  c->instructions = 0;
289
+
290
+  for (i = 0; i < 8; i++) {
291
+    c->dreg[i] = 0;
292
+  }
293
+
294
+  for (i = 0; i < 4; i++) {
295
+    c->sreg[i] = 0;
296
+  }
297
+
298
+  c->sreg[E86_REG_CS] = 0xf000;
299
+  c->ip = 0xfff0;
300
+  c->flg = 0x0000;
301
+
302
+  c->pq_cnt = 0;
303
+
304
+  c->prefix = 0;
305
+}
306
+
307
+e8086_t *e86_new (void)
308
+{
309
+  e8086_t *c;
310
+
311
+  c = (e8086_t *) malloc (sizeof (e8086_t));
312
+  if (c == NULL) {
313
+    return (NULL);
314
+  }
315
+
316
+  c->mem_get_uint8 = &e86_get_mem_uint8;
317
+  c->mem_get_uint16 = &e86_get_mem_uint16;
318
+  c->mem_set_uint8 = &e86_set_mem_uint8;
319
+  c->mem_set_uint16 = &e86_set_mem_uint16;
320
+
321
+  c->prt_get_uint8 = &e86_get_mem_uint8;
322
+  c->prt_get_uint16 = &e86_get_mem_uint16;
323
+  c->prt_set_uint8 = &e86_set_mem_uint8;
324
+  c->prt_set_uint16 = &e86_set_mem_uint16;
325
+
326
+  c->hook = NULL;
327
+  c->hook_ext = NULL;
328
+
329
+  c->clocks = 0;
330
+  c->instructions = 0;
331
+  c->delay = 0;
332
+
333
+  return (c);
334
+}
335
+
336
+void e86_del (e8086_t *c)
337
+{
338
+  free (c);
339
+}

+ 158
- 0
src/e8086/e8086.h View File

@@ -0,0 +1,158 @@
1
+/*****************************************************************************
2
+ * pce                                                                       *
3
+ *****************************************************************************/
4
+
5
+/*****************************************************************************
6
+ * File name:     e8086.h                                                    *
7
+ * Created:       1996-04-28 by Hampa Hug <hampa@hampa.ch>                   *
8
+ * Last modified: 2003-04-14 by Hampa Hug <hampa@hampa.ch>                   *
9
+ * Copyright:     (C) 1996-2003 by Hampa Hug <hampa@hampa.ch>                *
10
+ *****************************************************************************/
11
+
12
+/*****************************************************************************
13
+ * This program is free software. You can redistribute it and / or modify it *
14
+ * under the terms of the GNU General Public License version 2 as  published *
15
+ * by the Free Software Foundation.                                          *
16
+ *                                                                           *
17
+ * This program is distributed in the hope  that  it  will  be  useful,  but *
18
+ * WITHOUT  ANY   WARRANTY,   without   even   the   implied   warranty   of *
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  General *
20
+ * Public License for more details.                                          *
21
+ *****************************************************************************/
22
+
23
+/* $Id: e8086.h,v 1.1 2003/04/15 04:03:58 hampa Exp $ */
24
+
25
+
26
+#ifndef PCE_E8086_H
27
+#define PCE_E8086_H 1
28
+
29
+
30
+#include <stdio.h>
31
+
32
+
33
+/* CPU flags */
34
+#define E86_FLG_C 0x0001
35
+#define E86_FLG_P 0x0004
36
+#define E86_FLG_A 0x0010
37
+#define E86_FLG_Z 0x0040
38
+#define E86_FLG_S 0x0080
39
+#define E86_FLG_T 0x0100
40
+#define E86_FLG_I 0x0200
41
+#define E86_FLG_D 0x0400
42
+#define E86_FLG_O 0x0800
43
+
44
+/* 16 bit register values */
45
+#define E86_REG_AX 0
46
+#define E86_REG_CX 1
47
+#define E86_REG_DX 2
48
+#define E86_REG_BX 3
49
+#define E86_REG_SP 4
50
+#define E86_REG_BP 5
51
+#define E86_REG_SI 6
52
+#define E86_REG_DI 7
53
+
54
+/* 8 bit register values */
55
+#define E86_REG_AL 0
56
+#define E86_REG_CL 1
57
+#define E86_REG_DL 2
58
+#define E86_REG_BL 3
59
+#define E86_REG_AH 4
60
+#define E86_REG_CH 5
61
+#define E86_REG_DH 6
62
+#define E86_REG_BH 7
63
+
64
+/* Segment register values */
65
+#define E86_REG_ES 0
66
+#define E86_REG_CS 1
67
+#define E86_REG_SS 2
68
+#define E86_REG_DS 3
69
+
70
+#define E86_PREFIX_NEW  0x0001
71
+#define E86_PREFIX_SEG  0x0002
72
+#define E86_PREFIX_REP  0x0004
73
+#define E86_PREFIX_REPN 0x0008
74
+#define E86_PREFIX_LOCK 0x0010
75
+
76
+#define E86_PQ_SIZE 6
77
+
78
+
79
+typedef struct {
80
+  unsigned char (*mem_get_uint8) (void *mem, unsigned long addr);
81
+  unsigned short (*mem_get_uint16) (void *mem, unsigned long addr);
82
+
83
+  void (*mem_set_uint8) (void *mem, unsigned long addr, unsigned char val);
84
+  void (*mem_set_uint16) (void *mem, unsigned long addr, unsigned short val);
85
+
86
+  unsigned char (*prt_get_uint8) (void *mem, unsigned long addr);
87
+  unsigned short (*prt_get_uint16) (void *mem, unsigned long addr);
88
+
89
+  void (*prt_set_uint8) (void *mem, unsigned long addr, unsigned char val);
90
+  void (*prt_set_uint16) (void *mem, unsigned long addr, unsigned short val);
91
+
92
+  void (*hook) (void *ext, unsigned char op1, unsigned char op2);
93
+
94
+  void *mem;
95
+  void *prt;
96
+  void *hook_ext;
97
+
98
+  unsigned short dreg[8];
99
+  unsigned short sreg[4];
100
+  unsigned short ip;
101
+  unsigned short flg;
102
+
103
+  unsigned       pq_cnt;
104
+  unsigned char  pq[E86_PQ_SIZE];
105
+
106
+  unsigned       prefix;
107
+
108
+  unsigned short seg_override;
109
+
110
+  struct {
111
+    int            is_mem;
112
+    unsigned char  *data;
113
+    unsigned short seg;
114
+    unsigned short ofs;
115
+    unsigned short cnt;
116
+    unsigned long  delay;
117
+  } ea;
118
+
119
+  unsigned long  delay;
120
+
121
+  unsigned long  clocks;
122
+  unsigned long  instructions;
123
+} e8086_t;
124
+
125
+
126
+
127
+void e86_prt_state (e8086_t *c, FILE *fp);
128
+
129
+void e86_execute (e8086_t *c);
130
+void e86_clock (e8086_t *c);
131
+
132
+void e86_reset (e8086_t *c);
133
+
134
+e8086_t *e86_new (void);
135
+
136
+void e86_del (e8086_t *c);
137
+
138
+
139
+typedef struct {
140
+  unsigned short ip;
141
+
142
+  unsigned       dat_n;
143
+  unsigned char  dat[16];
144
+
145
+  char           op[64];
146
+
147
+  unsigned       arg_n;
148
+  char           arg1[64];
149
+  char           arg2[64];
150
+} e86_disasm_t;
151
+
152
+
153
+void e86_disasm (e86_disasm_t *op, unsigned char *src, unsigned short ip);
154
+void e86_disasm_mem (e8086_t *c, e86_disasm_t *op, unsigned short, unsigned short ip);
155
+void e86_disasm_cur (e8086_t *c, e86_disasm_t *op);
156
+
157
+
158
+#endif

+ 381
- 0
src/e8086/ea.c View File

@@ -0,0 +1,381 @@
1
+/*****************************************************************************
2
+ * pce                                                                       *
3
+ *****************************************************************************/
4
+
5
+/*****************************************************************************
6
+ * File name:     ea.c                                                       *
7
+ * Created:       1996-04-28 by Hampa Hug <hampa@hampa.ch>                   *
8
+ * Last modified: 2003-04-11 by Hampa Hug <hampa@hampa.ch>                   *
9
+ * Copyright:     (C) 1996-2003 by Hampa Hug <hampa@hampa.ch>                *
10
+ *****************************************************************************/
11
+
12
+/*****************************************************************************
13
+ * This program is free software. You can redistribute it and / or modify it *
14
+ * under the terms of the GNU General Public License version 2 as  published *
15
+ * by the Free Software Foundation.                                          *
16
+ *                                                                           *
17
+ * This program is distributed in the hope  that  it  will  be  useful,  but *
18
+ * WITHOUT  ANY   WARRANTY,   without   even   the   implied   warranty   of *
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  General *
20
+ * Public License for more details.                                          *
21
+ *****************************************************************************/
22
+
23
+/* $Id: ea.c,v 1.1 2003/04/15 04:03:58 hampa Exp $ */
24
+
25
+
26
+#include <pce.h>
27
+
28
+#include "e8086.h"
29
+#include "internal.h"
30
+
31
+
32
+/*************************************************************************
33
+ * EA functions
34
+ *************************************************************************/
35
+
36
+/* EA 00: [BX + SI] */
37
+static
38
+void ea_get00 (e8086_t *c)
39
+{
40
+  c->ea.is_mem = 1;
41
+  c->ea.seg = c->sreg[E86_REG_DS];
42
+  c->ea.ofs = c->dreg[E86_REG_BX] + c->dreg[E86_REG_SI];
43
+  c->ea.cnt = 1;
44
+  c->ea.delay = 7;
45
+}
46
+
47
+/* EA 01: [BX + DI] */
48
+static
49
+void ea_get01 (e8086_t *c)
50
+{
51
+  c->ea.is_mem = 1;
52
+  c->ea.seg = c->sreg[E86_REG_DS];
53
+  c->ea.ofs = c->dreg[E86_REG_BX] + c->dreg[E86_REG_DI];
54
+  c->ea.cnt = 1;
55
+  c->ea.delay = 8;
56
+}
57
+
58
+/* EA 02: [BP + SI] */
59
+static
60
+void ea_get02 (e8086_t *c)
61
+{
62
+  c->ea.is_mem = 1;
63
+  c->ea.seg = c->sreg[E86_REG_SS];
64
+  c->ea.ofs = c->dreg[E86_REG_BP] + c->dreg[E86_REG_SI];
65
+  c->ea.cnt = 1;
66
+  c->ea.delay = 8;
67
+}
68
+
69
+/* EA 03: [BP + DI] */
70
+static
71
+void ea_get03 (e8086_t *c)
72
+{
73
+  c->ea.is_mem = 1;
74
+  c->ea.seg = c->sreg[E86_REG_SS];
75
+  c->ea.ofs = c->dreg[E86_REG_BP] + c->dreg[E86_REG_DI];
76
+  c->ea.cnt = 1;
77
+  c->ea.delay = 7;
78
+}
79
+
80
+/* EA 04: [SI] */
81
+static
82
+void ea_get04 (e8086_t *c)
83
+{
84
+  c->ea.is_mem = 1;
85
+  c->ea.seg = c->sreg[E86_REG_DS];
86
+  c->ea.ofs = c->dreg[E86_REG_SI];
87
+  c->ea.cnt = 1;
88
+  c->ea.delay = 5;
89
+}
90
+
91
+/* EA 05: [DI] */
92
+static
93
+void ea_get05 (e8086_t *c)
94
+{
95
+  c->ea.is_mem = 1;
96
+  c->ea.seg = c->sreg[E86_REG_DS];
97
+  c->ea.ofs = c->dreg[E86_REG_DI];
98
+  c->ea.cnt = 1;
99
+  c->ea.delay = 5;
100
+}
101
+
102
+/* EA 06: [XXXX] */
103
+static
104
+void ea_get06 (e8086_t *c)
105
+{
106
+  c->ea.is_mem = 1;
107
+  c->ea.seg = c->sreg[E86_REG_DS];
108
+  c->ea.ofs = e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
109
+  c->ea.cnt = 3;
110
+  c->ea.delay = 6;
111
+}
112
+
113
+/* EA 07: [BX] */
114
+static
115
+void ea_get07 (e8086_t *c)
116
+{
117
+  c->ea.is_mem = 1;
118
+  c->ea.seg = c->sreg[E86_REG_DS];
119
+  c->ea.ofs = c->dreg[E86_REG_BX];
120
+  c->ea.cnt = 1;
121
+  c->ea.delay = 5;
122
+}
123
+
124
+/* EA 08: [BX + SI + XX] */
125
+static
126
+void ea_get08 (e8086_t *c)
127
+{
128
+  c->ea.is_mem = 1;
129
+  c->ea.seg = c->sreg[E86_REG_DS];
130
+  c->ea.ofs = c->dreg[E86_REG_BX] + c->dreg[E86_REG_SI] + e86_mk_sint16 (c->ea.data[1]);
131
+  c->ea.cnt = 2;
132
+  c->ea.delay = 11;
133
+}
134
+
135
+/* EA 09: [BX + DI + XX] */
136
+static
137
+void ea_get09 (e8086_t *c)
138
+{
139
+  c->ea.is_mem = 1;
140
+  c->ea.seg = c->sreg[E86_REG_DS];
141
+  c->ea.ofs = c->dreg[E86_REG_BX] + c->dreg[E86_REG_DI] + e86_mk_sint16 (c->ea.data[1]);
142
+  c->ea.cnt = 2;
143
+  c->ea.delay = 12;
144
+}
145
+
146
+/* EA 0A: [BP + SI + XX] */
147
+static
148
+void ea_get0a (e8086_t *c)
149
+{
150
+  c->ea.is_mem = 1;
151
+  c->ea.seg = c->sreg[E86_REG_SS];
152
+  c->ea.ofs = c->dreg[E86_REG_BP] + c->dreg[E86_REG_SI] + e86_mk_sint16 (c->ea.data[1]);
153
+  c->ea.cnt = 2;
154
+  c->ea.delay = 12;
155
+}
156
+
157
+/* EA 0B: [BP + DI + XX] */
158
+static
159
+void ea_get0b (e8086_t *c)
160
+{
161
+  c->ea.is_mem = 1;
162
+  c->ea.seg = c->sreg[E86_REG_SS];
163
+  c->ea.ofs = c->dreg[E86_REG_BP] + c->dreg[E86_REG_DI] + e86_mk_sint16 (c->ea.data[1]);
164
+  c->ea.cnt = 2;
165
+  c->ea.delay = 11;
166
+}
167
+
168
+/* EA 0C: [SI + XX] */
169
+static
170
+void ea_get0c (e8086_t *c)
171
+{
172
+  c->ea.is_mem = 1;
173
+  c->ea.seg = c->sreg[E86_REG_DS];
174
+  c->ea.ofs = c->dreg[E86_REG_SI] + e86_mk_sint16 (c->ea.data[1]);
175
+  c->ea.cnt = 2;
176
+  c->ea.delay = 5;
177
+}
178
+
179
+/* EA 0D: [DI + XX] */
180
+static
181
+void ea_get0d (e8086_t *c)
182
+{
183
+  c->ea.is_mem = 1;
184
+  c->ea.seg = c->sreg[E86_REG_DS];
185
+  c->ea.ofs = c->dreg[E86_REG_DI] + e86_mk_sint16 (c->ea.data[1]);
186
+  c->ea.cnt = 2;
187
+  c->ea.delay = 5;
188
+}
189
+
190
+/* EA 0E: [BP + XX] */
191
+static
192
+void ea_get0e (e8086_t *c)
193
+{
194
+  c->ea.is_mem = 1;
195
+  c->ea.seg = c->sreg[E86_REG_SS];
196
+  c->ea.ofs = c->dreg[E86_REG_BP] + e86_mk_sint16 (c->ea.data[1]);
197
+  c->ea.cnt = 2;
198
+  c->ea.delay = 5;
199
+}
200
+
201
+/* EA 0F: [BX + XX] */
202
+static
203
+void ea_get0f (e8086_t *c)
204
+{
205
+  c->ea.is_mem = 1;
206
+  c->ea.seg = c->sreg[E86_REG_DS];
207
+  c->ea.ofs = c->dreg[E86_REG_BX] + e86_mk_sint16 (c->ea.data[1]);
208
+  c->ea.cnt = 2;
209
+  c->ea.delay = 5;
210
+}
211
+
212
+/* EA 10: [BX + SI + XXXX] */
213
+static
214
+void ea_get10 (e8086_t *c)
215
+{
216
+  c->ea.is_mem = 1;
217
+  c->ea.seg = c->sreg[E86_REG_DS];
218
+  c->ea.ofs = c->dreg[E86_REG_BX] + c->dreg[E86_REG_SI];
219
+  c->ea.ofs += e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
220
+  c->ea.cnt = 3;
221
+  c->ea.delay = 11;
222
+}
223
+
224
+/* EA 11: [BX + DI + XXXX] */
225
+static
226
+void ea_get11 (e8086_t *c)
227
+{
228
+  c->ea.is_mem = 1;
229
+  c->ea.seg = c->sreg[E86_REG_DS];
230
+  c->ea.ofs = c->dreg[E86_REG_BX] + c->dreg[E86_REG_DI];
231
+  c->ea.ofs += e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
232
+  c->ea.cnt = 3;
233
+  c->ea.delay = 12;
234
+}
235
+
236
+/* EA 12: [BP + SI + XXXX] */
237
+static
238
+void ea_get12 (e8086_t *c)
239
+{
240
+  c->ea.is_mem = 1;
241
+  c->ea.seg = c->sreg[E86_REG_SS];
242
+  c->ea.ofs = c->dreg[E86_REG_BP] + c->dreg[E86_REG_SI];
243
+  c->ea.ofs += e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
244
+  c->ea.cnt = 3;
245
+  c->ea.delay = 12;
246
+}
247
+
248
+/* EA 13: [BP + DI + XXXX] */
249
+static
250
+void ea_get13 (e8086_t *c)
251
+{
252
+  c->ea.is_mem = 1;
253
+  c->ea.seg = c->sreg[E86_REG_SS];
254
+  c->ea.ofs = c->dreg[E86_REG_BP] + c->dreg[E86_REG_DI];
255
+  c->ea.ofs += e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
256
+  c->ea.cnt = 3;
257
+  c->ea.delay = 11;
258
+}
259
+
260
+/* EA 14: [SI + XXXX] */
261
+static
262
+void ea_get14 (e8086_t *c)
263
+{
264
+  c->ea.is_mem = 1;
265
+  c->ea.seg = c->sreg[E86_REG_DS];
266
+  c->ea.ofs = c->dreg[E86_REG_SI];
267
+  c->ea.ofs += e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
268
+  c->ea.cnt = 3;
269
+  c->ea.delay = 5;
270
+}
271
+
272
+/* EA 15: [DI + XXXX] */
273
+static
274
+void ea_get15 (e8086_t *c)
275
+{
276
+  c->ea.is_mem = 1;
277
+  c->ea.seg = c->sreg[E86_REG_DS];
278
+  c->ea.ofs = c->dreg[E86_REG_DI];
279
+  c->ea.ofs += e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
280
+  c->ea.cnt = 3;
281
+  c->ea.delay = 5;
282
+}
283
+
284
+/* EA 16: [BP + XXXX] */
285
+static
286
+void ea_get16 (e8086_t *c)
287
+{
288
+  c->ea.is_mem = 1;
289
+  c->ea.seg = c->sreg[E86_REG_SS];
290
+  c->ea.ofs = c->dreg[E86_REG_BP];
291
+  c->ea.ofs += e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
292
+  c->ea.cnt = 3;
293
+  c->ea.delay = 5;
294
+}
295
+
296
+/* EA 17: [BX + XXXX] */
297
+static
298
+void ea_get17 (e8086_t *c)
299
+{
300
+  c->ea.is_mem = 1;
301
+  c->ea.seg = c->sreg[E86_REG_DS];
302
+  c->ea.ofs = c->dreg[E86_REG_BX];
303
+  c->ea.ofs += e86_mk_uint16 (c->ea.data[1], c->ea.data[2]);
304
+  c->ea.cnt = 3;
305
+  c->ea.delay = 5;
306
+}
307
+
308
+/* EA 18-1F: REG */
309
+static
310
+void ea_get18 (e8086_t *c)
311
+{
312
+  c->ea.is_mem = 0;
313
+  c->ea.seg = 0;
314
+  c->ea.ofs = c->ea.data[0] & 7;
315
+  c->ea.cnt = 1;
316
+  c->ea.delay = 0;
317
+}
318
+
319
+e86_ea_f e86_ea[32] = {
320
+  &ea_get00, &ea_get01, &ea_get02, &ea_get03,
321
+  &ea_get04, &ea_get05, &ea_get06, &ea_get07,
322
+  &ea_get08, &ea_get09, &ea_get0a, &ea_get0b,
323
+  &ea_get0c, &ea_get0d, &ea_get0e, &ea_get0f,
324
+  &ea_get10, &ea_get11, &ea_get12, &ea_get13,
325
+  &ea_get14, &ea_get15, &ea_get16, &ea_get17,
326
+  &ea_get18, &ea_get18, &ea_get18, &ea_get18,
327
+  &ea_get18, &ea_get18, &ea_get18, &ea_get18
328
+};
329
+
330
+void e86_get_ea_ptr (e8086_t *c, unsigned char *ea)
331
+{
332
+  unsigned fea;
333
+
334
+  c->ea.data = ea;
335
+
336
+  fea = (ea[0] & 7) | ((ea[0] & 0xc0) >> 3);
337
+
338
+  e86_ea[fea] (c);
339
+
340
+  if (c->prefix & E86_PREFIX_SEG) {
341
+    c->ea.seg = c->seg_override;
342
+  }
343
+}
344
+
345
+unsigned char e86_get_ea8 (e8086_t *c)
346
+{
347
+  if (c->ea.is_mem) {
348
+    return (e86_get_mem8 (c, c->ea.seg, c->ea.ofs));
349
+  }
350
+
351
+  return (e86_get_reg8 (c, c->ea.ofs));
352
+}
353
+
354
+unsigned short e86_get_ea16 (e8086_t *c)
355
+{
356
+  if (c->ea.is_mem) {
357
+    return (e86_get_mem16 (c, c->ea.seg, c->ea.ofs));
358
+  }
359
+
360
+  return (e86_get_reg16 (c, c->ea.ofs));
361
+}
362
+
363
+void e86_set_ea8 (e8086_t *c, unsigned char val)
364
+{
365
+  if (c->ea.is_mem) {
366
+    e86_set_mem8 (c, c->ea.seg, c->ea.ofs, val);
367
+  }
368
+  else {
369
+    e86_set_reg8 (c, c->ea.ofs, val);
370
+  }
371
+}
372
+
373
+void e86_set_ea16 (e8086_t *c, unsigned short val)
374
+{
375
+  if (c->ea.is_mem) {
376
+    e86_set_mem16 (c, c->ea.seg, c->ea.ofs, val);
377
+  }
378
+  else {
379
+    e86_set_reg16 (c, c->ea.ofs, val);
380
+  }
381
+}

+ 145
- 0
src/e8086/internal.h View File

@@ -0,0 +1,145 @@
1
+/*****************************************************************************
2
+ * pce                                                                       *
3
+ *****************************************************************************/
4
+
5
+/*****************************************************************************
6
+ * File name:     internal.h                                                 *
7
+ * Created:       2003-04-10 by Hampa Hug <hampa@hampa.ch>                   *
8
+ * Last modified: 2003-04-14 by Hampa Hug <hampa@hampa.ch>                   *
9
+ * Copyright:     (C) 2003 by Hampa Hug <hampa@hampa.ch>                     *
10
+ *****************************************************************************/
11
+
12
+/*****************************************************************************
13
+ * This program is free software. You can redistribute it and / or modify it *
14
+ * under the terms of the GNU General Public License version 2 as  published *
15
+ * by the Free Software Foundation.                                          *
16
+ *                                                                           *
17
+ * This program is distributed in the hope  that  it  will  be  useful,  but *
18
+ * WITHOUT  ANY   WARRANTY,   without   even   the   implied   warranty   of *
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  General *
20
+ * Public License for more details.                                          *
21
+ *****************************************************************************/
22
+
23
+/* $Id: internal.h,v 1.1 2003/04/15 04:03:58 hampa Exp $ */
24
+
25
+
26
+#ifndef PCE_E8086_INTERNAL_H
27
+#define PCE_E8086_INTERNAL_H 1
28
+
29
+
30
+#include "e8086.h"
31
+
32
+
33
+#define FLG_STD (E86_FLG_C | E86_FLG_O | E86_FLG_Z | E86_FLG_S | E86_FLG_P)
34
+
35
+
36
+#define e86_get_linear(seg, ofs) \
37
+  (((seg) << 4) + ((ofs) & 0xffff))
38
+
39
+#define e86_mk_uint16(lo, hi) \
40
+  (((hi) << 8) | (lo))
41
+
42
+#define e86_mk_sint16(lo) \
43
+  (((lo) & 0x80) ? ((lo) | 0xff00) : ((lo) & 0xff))
44
+
45
+#define e86_add_sint8(w, b) \
46
+  ((((b) & 0x80) ? ((w) + ((b) | 0xff00)) : ((w) + ((b) & 0xff))) & 0xffff)
47
+
48
+#define e86_get_mem8(cpu, seg, ofs) \
49
+  (cpu)->mem_get_uint8 ((cpu)->mem, e86_get_linear (seg, ofs) & 0xfffff)
50
+
51
+#define e86_get_mem16(cpu, seg, ofs) \
52
+  (cpu)->mem_get_uint16 ((cpu)->mem, e86_get_linear (seg, ofs) & 0xfffff)
53
+
54
+#define e86_set_mem8(cpu, seg, ofs, val) \
55
+  (cpu)->mem_set_uint8 ((cpu)->mem, e86_get_linear (seg, ofs) & 0xfffff, val)
56
+
57
+#define e86_set_mem16(cpu, seg, ofs, val) \
58
+  (cpu)->mem_set_uint16 ((cpu)->mem, e86_get_linear (seg, ofs) & 0xfffff, val)
59
+
60
+#define e86_get_prt8(cpu, ofs) \
61
+  (cpu)->prt_get_uint8 ((cpu)->prt, ofs)
62
+
63
+#define e86_get_prt16(cpu, ofs) \
64
+  (cpu)->prt_get_uint16 ((cpu)->prt, ofs)
65
+
66
+#define e86_set_prt8(cpu, ofs, val) \
67
+  (cpu)->prt_set_uint8 ((cpu)->prt, ofs, val)
68
+
69
+#define e86_set_prt16(cpu, ofs, val) \
70
+  (cpu)->prt_set_uint16 ((cpu)->prt, ofs, val)
71
+
72
+#define e86_get_reg8(cpu, reg) \
73
+  ((((reg) & 4) ? ((cpu)->dreg[(reg) & 3] >> 8) : (cpu)->dreg[(reg) & 3]) & 0xff)
74
+
75
+#define e86_get_reg16(cpu, reg) \
76
+  ((cpu)->dreg[(reg) & 7])
77
+
78
+#define e86_set_reg8(cpu, reg, val) \
79
+  if (reg & 4) { \
80
+    (cpu)->dreg[(reg) & 3] &= 0x00ff; \
81
+    (cpu)->dreg[(reg) & 3] |= (val) << 8; \
82
+  } \
83
+  else { \
84
+    (cpu)->dreg[(reg) & 3] &= 0xff00; \
85
+    (cpu)->dreg[(reg) & 3] |= (val); \
86
+  }
87
+
88
+#define e86_set_reg16(cpu, reg, val) \
89
+  (cpu)->dreg[(reg) & 7] = (val);
90
+
91
+#define e86_get_flg(cpu, f) \
92
+  (((cpu)->flg & (f)) != 0)
93
+
94
+#define e86_set_flg(cpu, f, v) \
95
+  if (v) (c)->flg |= (f); else (c)->flg &= ~(f);
96
+
97
+#define e86_get_cf(cpu) \
98
+  (((cpu)->flg & E86_FLG_C) != 0)
99
+
100
+#define e86_set_cf(cpu, v) \
101
+  if (v) (c)->flg |= E86_FLG_C; else (c)->flg &= ~E86_FLG_C;
102
+
103
+#define e86_get_of(cpu) \
104
+  (((cpu)->flg & E86_FLG_O) != 0)
105
+
106
+#define e86_set_of(cpu, v) \
107
+  if (v) (c)->flg |= E86_FLG_O; else (c)->flg &= ~E86_FLG_O;
108
+
109
+#define e86_get_seg(cpu, seg) \
110
+  ((cpu)->prefix & E86_PREFIX_SEG) ? (cpu)->seg_override : (cpu)->sreg[(seg)];
111
+
112
+#define e86_add_uint4(s1, s2) \
113
+  (((s1) & 0x0f) + ((s2) & 0x0f))
114
+
115
+#define e86_sub_uint4(s1, s2) \
116
+  (((s1) & 0x0f) - ((s2) & 0x0f))
117
+
118
+
119
+typedef unsigned (*e86_opcode_f) (e8086_t *c);
120
+
121
+typedef void (*e86_ea_f) (e8086_t *c);
122
+
123
+
124
+extern e86_opcode_f e86_opcodes[256];
125
+
126
+extern e86_ea_f e86_ea[32];
127
+
128
+
129
+void e86_get_ea_ptr (e8086_t *c, unsigned char *ea);
130
+
131
+unsigned char e86_get_ea8 (e8086_t *c);
132
+unsigned short e86_get_ea16 (e8086_t *c);
133
+void e86_set_ea8 (e8086_t *c, unsigned char val);
134
+void e86_set_ea16 (e8086_t *c, unsigned short val);
135
+
136
+void e86_pq_init (e8086_t *c);
137
+void e86_pq_fill (e8086_t *c);
138
+void e86_pq_adjust (e8086_t *c, unsigned cnt);
139
+
140
+void e86_set_flags8 (e8086_t *c, unsigned short mask, unsigned short dst, unsigned short src);
141
+void e86_set_flags16 (e8086_t *c, unsigned short mask, unsigned long dst, unsigned long src);
142
+void e86_set_flags_af (e8086_t *c, unsigned d);
143
+
144
+
145
+#endif

+ 4244
- 0
src/e8086/microcode.c
File diff suppressed because it is too large
View File


+ 223
- 0
src/floppy.c View File

@@ -0,0 +1,223 @@
1
+/*****************************************************************************
2
+ * pce                                                                       *
3
+ *****************************************************************************/
4
+
5
+/*****************************************************************************
6
+ * File name:     floppy.c                                                   *
7
+ * Created:       2003-04-14 by Hampa Hug <hampa@hampa.ch>                   *
8
+ * Last modified: 2003-04-14 by Hampa Hug <hampa@hampa.ch>                   *
9
+ * Copyright:     (C) 1996-2003 by Hampa Hug <hampa@hampa.ch>                *
10
+ *****************************************************************************/
11
+
12
+/*****************************************************************************
13
+ * This program is free software. You can redistribute it and / or modify it *
14
+ * under the terms of the GNU General Public License version 2 as  published *
15
+ * by the Free Software Foundation.                                          *
16
+ *                                                                           *
17
+ * This program is distributed in the hope  that  it  will  be  useful,  but *
18
+ * WITHOUT  ANY   WARRANTY,   without   even   the   implied   warranty   of *
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  General *
20
+ * Public License for more details.                                          *
21
+ *****************************************************************************/
22
+
23
+/* $Id: floppy.c,v 1.1 2003/04/15 04:03:56 hampa Exp $ */
24
+
25
+
26
+#include <stdio.h>
27
+
28
+#include <pce.h>
29
+
30
+#include <unistd.h>
31
+#include <termios.h>
32
+#include <fcntl.h>
33
+#include <sys/types.h>
34
+#include <sys/poll.h>
35
+
36
+
37
+floppy_t *flp_new (unsigned c, unsigned h, unsigned s)
38
+{
39
+  floppy_t *flp;
40
+
41
+  flp = (floppy_t *) malloc (sizeof (floppy_t));
42
+  if (flp == NULL) {
43
+    return (NULL);
44
+  }
45
+
46
+  flp->c = c;
47
+  flp->h = h;
48
+  flp->s = s;
49
+  flp->size = c * h * s * 512UL;
50
+
51
+  flp->data = (unsigned char *) malloc (flp->size);
52
+  if (flp->data == NULL) {
53
+    free (flp);
54
+    return (NULL);
55
+  }
56
+
57
+  return (flp);
58
+}
59
+
60
+void flp_del (floppy_t *flp)
61
+{
62
+  if (flp != NULL) {
63
+    free (flp->data);
64
+    free (flp);
65
+  }
66
+}
67
+
68
+int flp_load_img (floppy_t *flp, const char *fname)
69
+{
70
+  FILE *fp;
71
+
72
+  fp = fopen (fname, "rb");
73
+  if (fp == NULL) {
74
+    return (1);
75
+  }
76
+
77
+  if (fread (flp->data, 1, flp->size, fp) != flp->size) {
78
+    return (1);
79
+  }
80
+
81
+  return (0);
82
+}
83
+
84
+void flp_int13_set_status (floppy_t *flp, e8086_t *cpu, unsigned val)
85
+{
86
+  cpu->dreg[E86_REG_AX] &= 0x00ff;
87
+  cpu->dreg[E86_REG_AX] |= (val & 0xff) << 8;
88
+
89
+  cpu->mem_set_uint8 (cpu->mem, 0x441, val);
90
+
91
+  if (val == 0) {
92
+    cpu->flg &= ~E86_FLG_C;
93
+  }
94
+  else {
95
+    cpu->flg |= E86_FLG_C;
96
+  }
97
+}
98
+
99
+void flp_int13_read (floppy_t *flp, e8086_t *cpu)
100
+{
101
+  unsigned cnt;
102
+  unsigned drive;
103
+  unsigned c, h, s;
104
+  unsigned seg, ofs;
105
+  unsigned long i, n;
106
+
107
+  drive = cpu->dreg[E86_REG_DX] & 0xff;
108
+
109
+  cnt = cpu->dreg[E86_REG_AX] & 0xff;
110
+  c = ((cpu->dreg[E86_REG_CX] >> 8) & 0xff);
111
+  c |= ((cpu->dreg[E86_REG_CX] >> 6) & 0x03) << 8;
112
+  h = (cpu->dreg[E86_REG_DX] >> 8) & 0xff;
113
+  s = cpu->dreg[E86_REG_CX] & 0x3f;
114
+
115
+  if ((s < 1) || (s > flp->s) || (h >= flp->h) || (c >= flp->c)) {
116
+    flp_int13_set_status (flp, cpu, 0x04);
117
+    return;
118
+  }
119
+
120
+  seg = cpu->sreg[E86_REG_ES];
121
+  ofs = cpu->dreg[E86_REG_BX];
122
+
123
+  i = 512UL * ((c * flp->h + h) * flp->s + s - 1);
124
+  n = 512UL * cnt;
125
+
126
+  fprintf (stderr, "int13: read %u at %u/%u/%u (%lu)\n", cnt, c, h, s, i);
127
+
128
+  while (n > 0) {
129
+    cpu->mem_set_uint8 (cpu->mem, (seg << 4) + ofs, flp->data[i]);
130
+    i += 1;
131
+    n -= 1;
132
+    ofs = (ofs + 1) & 0xffff;
133
+  }
134
+
135
+  flp_int13_set_status (flp, cpu, 0);
136
+}
137
+
138
+void flp_int13_write (floppy_t *flp, e8086_t *cpu)
139
+{
140
+  unsigned cnt;
141
+  unsigned drive;
142
+  unsigned c, h, s;
143
+  unsigned seg, ofs;
144
+  unsigned long i, n;
145
+
146
+  drive = cpu->dreg[E86_REG_DX] & 0xff;
147
+
148
+  cnt = cpu->dreg[E86_REG_AX] & 0xff;
149
+  c = ((cpu->dreg[E86_REG_CX] >> 8) & 0xff);
150
+  c |= ((cpu->dreg[E86_REG_CX] >> 6) & 0x03) << 8;
151
+  h = (cpu->dreg[E86_REG_DX] >> 8) & 0xff;
152
+  s = cpu->dreg[E86_REG_CX] & 0x3f;
153
+
154
+  if ((s < 1) || (s > flp->s) || (h >= flp->h) || (c >= flp->c)) {
155
+    flp_int13_set_status (flp, cpu, 0x04);
156
+    return;
157
+  }
158
+
159
+  seg = cpu->sreg[E86_REG_ES];
160
+  ofs = cpu->dreg[E86_REG_BX];
161
+
162
+  i = 512UL * ((c * flp->h + h) * flp->s + s - 1);
163
+  n = 512UL * cnt;
164
+
165
+  fprintf (stderr, "int13: write %u at %u/%u/%u (%lu)\n", cnt, c, h, s, i);
166
+
167
+  while (n > 0) {
168
+    flp->data[i] = cpu->mem_get_uint8 (cpu->mem, (seg << 4) + ofs);
169
+    i += 1;
170
+    n -= 1;
171
+    ofs = (ofs + 1) & 0xffff;
172
+  }
173
+
174
+  flp_int13_set_status (flp, cpu, 0);
175
+}
176
+
177
+void flp_int_13 (floppy_t *flp, e8086_t *cpu)
178
+{
179
+  unsigned func;
180
+
181
+  func = (cpu->dreg[E86_REG_AX] >> 8) & 0xff;
182
+
183
+  switch (func) {
184
+    case 0x00:
185
+      flp_int13_set_status (flp, cpu, 0);
186
+      break;
187
+
188
+    case 0x01:
189
+      flp_int13_set_status (flp, cpu, cpu->mem_get_uint8 (cpu->mem, 0x441));
190
+      break;
191
+
192
+    case 0x02:
193
+      flp_int13_read (flp, cpu);
194
+      break;
195
+
196
+    case 0x03:
197
+      flp_int13_write (flp, cpu);
198
+      break;
199
+
200
+    case 0x04:
201
+      flp_int13_set_status (flp, cpu, 0);
202
+      break;
203
+
204
+    case 0x08:
205
+      if ((cpu->dreg[E86_REG_DX] & 0xff) > 0) {
206
+        flp_int13_set_status (flp, cpu, 1);
207
+        return;
208
+      }
209
+      cpu->dreg[E86_REG_CX] = (flp->c << 8) | flp->s;
210
+      cpu->dreg[E86_REG_DX] = (flp->h << 8);
211
+      flp_int13_set_status (flp, cpu, 0);
212
+      break;
213
+
214
+    case 0x15: