Date : Sun, 24 Jan 1993 15:01:31 -0500
From : Jay Sage <sage@ll.mit.edu>
Subject: Re: 8080/8085/Z80 Code Identifier
John Winslade asked about determining if a given COM file included Z80 or
8085 code in addition to 8080 code. A few people offered answers. One was
the following:
>> There's a trick I SORTA remember which uses the Z80's additional overflow
>> capability of the parity flag.
This is not the answer to the question at hand. It is a method of
determining within a program what kind of processor it is actually running
on at the time. It is often used in programs that require a Z80 to make
sure they are NOT running on just an 8080 so that they can abort gracefully
before they go up in flames.
In fact, as one reply noted, it would be extremely difficult to determine
by any simple analysis what opcodes appear in a COM file, since there is no
easy way to discriminate between code and data. However, there is a rather
nice way to find out if you have, of all things, a DOS machine with the
22NICE emulator. If I remember correctly, it can optionally be set up to
emulate only 8080 opcodes or to emulate the full Z80 set. In the former
mode, it will trap Z80 opcodes as illegal. This approach works because the
emulator actually tries to execute the program, and that distinguishes
between data and code.
It would be possible to do the same thing under CP/M itself, namely, to
write an 8080/Z80 emulator (strange to emulate a processor on the very
processor that is being emulated!). In fact, it may even be that the DSD
(Dynamic Screen Debugger) tool already does this (it certainly could be made
to do it), since it supports an emulation mode in which it does not actually
run the code (as DDT and SID do) but emulates (simulates) its operation
while allowing a user routine to evaluate whatever one wishes on each step
of the code.