[comp.os.cpm] CP/M Emulators

darcy@druid.uucp (D'Arcy J.M. Cain) (03/31/91)

In article <9103310818.AA10937@ucbvax.Berkeley.EDU> Alexandre Montaron writes:
>   Someone is talking about a CP/M emulator on Unix system ???
>So, the Unix system that i'll bought is based on a Z8000 perhaps is it
>possible to make a more efficient emulation because only op_codes changes
>(number not mnemonic)... The Z8000 has sixteen 16bits register and the

If you have source it probably makes sense to convert it to C and run it
native on whatever platform.  Emulators should take binaries and run them
direct.  If you want an emulator try my cp-emulate in pub/druid at ftp site
sipb.mit.edu (thanks to eichin@athena.mit.edu for making the space available.)
It is not completely finished but it does seem to be working.

While I am at it would anyone who has been playing with it please let me
know what problems you might be having with it.  I expect to get back to
it one of these days and finish it and would like to fix any problems
found as well.  Thanks.

-- 
D'Arcy J.M. Cain (darcy@druid)     |
D'Arcy Cain Consulting             |   There's no government
Toronto, Ontario, Canada           |   like no government!
+1 416 424 2871                    |

wilker@gauss.math.purdue.edu (Clarence Wilkerson) (04/01/91)

The main hassles in writing a 8080 emulator ( or worse, Z80 emulator)
are getting the condition codes (flags) exactly right. Another
slowdown is if the host machine for the emulator has a different
byte order than the 8080 for words. To my knowledge, this stacks
up as
8080, 80X86, VAX, 32032?? ....LITTLE_ENDIAN
680X0, RS6000, SPARC    BIG_ENDIAN.
But the flags are a major slowdown, and more if you include
parity, half parity, and so on. 
In C ,one has to do extra arithmetic to compute the flags, such
as carrying more digits to detect overflows. In assembler,
you can try to match your host CPU flags to the 8080/Z80 flags,
but there are lots of gotchas there. Later versions of Joan Riff's
Z80MU do a pretty good job at decent speed on a 80286 ( say,
equivalent to a 1.2 mhz z80 if run on a 12 mhz 80286 ). I think this
could be sped up some by unrolling the jumps into more code, etc,
but I doubt if anything would give a factor of 2 better.

I haven't "benchmarked" any emulators written in C running under
UNIX. The version I have running on a sparc feels like it's connected
to a 600 baud modem from the command line, but the disk performance
is quite peppy, so it probably assembles stuff at the rate of my
old H89. I tried the code on a IBM RS6000. It ran, but the stty
stuff on IBM style of unix is enough different that the terminal
handling is screwed up.
Clarence

asfy@vax5.cit.cornell.edu (04/02/91)

In article <9163@mentor.cc.purdue.edu>,
wilker@gauss.math.purdue.edu (Clarence Wilkerson) writes:
> The main hassles in writing a 8080 emulator ( or worse, Z80 emulator)
> are getting the condition codes (flags) exactly right. Another
> slowdown is if the host machine for the emulator has a different
> byte order than the 8080 for words. To my knowledge, this stacks
> up as
> 8080, 80X86, VAX, 32032?? ....LITTLE_ENDIAN
> 680X0, RS6000, SPARC    BIG_ENDIAN.
> But the flags are a major slowdown, and more if you include
> parity, half parity, and so on.
> In C ,one has to do extra arithmetic to compute the flags, such
> as carrying more digits to detect overflows. In assembler,
> you can try to match your host CPU flags to the 8080/Z80 flags,
> but there are lots of gotchas there. Later versions of Joan Riff's
[...]
> Clarence

There's a sneaky way around this that should do wonders:  If
you're on a big enough machine with enough memory, you
precalculate all possible 8-bit adds and subtracts, with and
without carries, and a couple of basic logical operations.  You
end up with a small pile of 128k tables-- which is just fine in
this day of 4 MB SIMM modules.  The entire addition or
subtraction, complete with flags register, is reduced to a table
lookup.

All this to emulate a 64k machine running an 8k operating
system...

Are you the person responsible for the Japanese CP/M emulator
running on the Sun at math.purdue.edu?  Do you know where I can
get the source to that thing?  I'm occasionally working on my own
emulator :) and I like to see what other people have done.

  --jh

wilker@descartes.math.purdue.edu (Clarence Wilkerson) (04/03/91)

I'm responsible for the CP/M emulator running on 128.210.3.18. I
imported the source
from utsun in Japan a year or so ago, and managed to get it to run. The
docs were
in kanji and didn't print! 
  I'm willing to post the source, but the documentation on hooking it up
to a cp/m
binary system is very incomplete. It only does 8080 code, and I don't
have any PD 
CP/M replacements in strict 8080 code, so it's running DRI CP/M 2.2 out
of the box.
The bios is a stub of course.
Clarence