[comp.sources.d] Z80 -> 8080 converter

stein@rocksanne.UUCP (Adam Stein) (01/10/87)

I am look for a Z80 to 8080 program converter.  My C compiler only comes with
an 8080 assembler.  This is for a TRS-80 Model 4.  I don't care what language
it's written in.  I would appreciate any help on this.

						Adam Stein

seismo!rochester!rocksanne!stein - Work
seismo!rochester!ritcv!aes0972 - School

det@herman.UUCP (Derek Terveer) (01/13/87)

In article <249@rocksanne.UUCP>, stein@rocksanne.UUCP (Adam Stein) writes:
> I am look for a Z80 to 8080 program converter.  My C compiler only comes with
> an 8080 assembler.  This is for a TRS-80 Model 4.  I don't care what language
> it's written in.  I would appreciate any help on this.

I believe that z80 has a mere two instructions that 8080 doesn't have.
Therefore, most likely, your z80 program will run unchanged with the 8080
assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
those two instructions that is)

ken@rochester.ARPA (SKY) (01/14/87)

|> I am look for a Z80 to 8080 program converter.  My C compiler only comes with
|
|I believe that z80 has a mere two instructions that 8080 doesn't have.

If I am not mistaken, the poster wanted a assembler to assembler
converter.  You can find one on the SIMTEL20 archives as XIZI.LBR in
the CPMUG collection. Sorry, don't know the archive number offhand.

	Ken

PS: Also there are more than 2 extra instructions in the Z80. You are
thinking of the 8085 perhaps.

jpn@teddy.UUCP (John P. Nelson) (01/14/87)

>In article <249@rocksanne.UUCP>, stein@rocksanne.UUCP (Adam Stein) writes:
>> I am look for a Z80 to 8080 program converter.

In article <175@herman.UUCP> det@herman.UUCP (Derek Terveer) writes:
>I believe that z80 has a mere two instructions that 8080 doesn't have.
>(I hope i'm right in this).

No, that's not right.  First, a "Z80" assembler usually uses different
mnemonics even when the object code instruction is identical (Z80 has
a single LD mnemonic to move data around, but the standard 8080 has
lots of mnemonics for the instruction variations).  Also, the Z80 has
extra registers, and instructions to deal with them, as well as lots of
new general instructions (bit set/clear etc.).

I have seen Z80->8080 translaters that will even translate the new
Z80 instructions to DB and DW psuedo ops - inserting constants which
just happen to correspond to the new Z80 instructions.  Not very
readable, but it will assemble a working program.

Perhaps Derek was thinking about an 8085, which is an 8080 with two
new system type instructions.

dcm@mimir.dmt.oz (Dennis Mills) (01/14/87)

In article <175@herman.UUCP>, det@herman.UUCP (Derek Terveer) writes:
> I believe that z80 has a mere two instructions that 8080 doesn't have.
> Therefore, most likely, your z80 program will run unchanged with the 8080
> assembler (I hope i'm right in this).

Sorry...you're not! The Z80 has quite a considerable number of instructions
in addition to the 8080 ones, a large number of which are the consequence
of architectural differences such as index registers etc etc which the
Z80 has and the 8080 does not.

Dennis
-- 
Dennis Mills,					PHONE:  +61 (03)487-9258
CSIRO Division of Manufacturing Technology,	ACSNET: dcm@mimir.dmt.oz
Cnr Albert and Raglan Streets, Preston
Victoria, Australia, 3072.

ken@argus.UUCP (Kenneth Ng) (01/15/87)

In article <175@herman.UUCP>, det@herman.UUCP (Derek Terveer) writes:
> In article <249@rocksanne.UUCP>, stein@rocksanne.UUCP (Adam Stein) writes:
> > I am look for a Z80 to 8080 program converter.  My C compiler only comes with
> > an 8080 assembler.  This is for a TRS-80 Model 4.  I don't care what language
> > it's written in.  I would appreciate any help on this.
> 
> I believe that z80 has a mere two instructions that 8080 doesn't have.
> Therefore, most likely, your z80 program will run unchanged with the 8080
> assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
> those two instructions that is)

The z80 has a LOT more than 2 more op codes over the 8080.


-- 
Kenneth Ng: Post office: NJIT - CCCC, Newark New Jersey  07102
uucp !ihnp4!allegra!bellcore!argus!ken
     ***   WARNING:  NOT ken@bellcore.uucp ***
bitnet(prefered) ken@orion.bitnet

Gillian: "Are you sure you won't change your mind?"
Spock: "Is there something wrong with the one I have?"

straka@ihlpf.UUCP (01/15/87)

> > I am look for a Z80 to 8080 program converter.  My C compiler only comes with
> I believe that z80 has a mere two instructions that 8080 doesn't have.
> Therefore, most likely, your z80 program will run unchanged with the 8080
> assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
> those two instructions that is)

If my merory serves me correctly, the Z80 also has a *pair* of register
sets that the user can toggle between, whereas the 8080 only has one set
of registers.  Also, the Z80 has a few auto-incrementing opcodes which
help in block-mode data transfers.  Perhaps the previous poster was
referring to the difference between the 8080 and the 8085 (which *are*
almost identical for 5v-only power supply and 2 (RIM? or similar) opcodes).

I'm confident that the job could be done without a real lot of effort,
but Z80 code is not downward compatible with 8080 code.

Hope this helps.

-- 
Rich Straka     ihnp4!ihlpf!straka

perkins@bnrmtv.UUCP (Henry Perkins) (01/15/87)

> I believe that z80 has a mere two instructions that 8080 doesn't have.
> Therefore, most likely, your z80 program will run unchanged with the 8080
> assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
> those two instructions that is)

Sorry, you're thinking of the 8085, not the Z80.  (The two extra
instructions are RIM and SIM.)  The Z80 instruction set is rather
more complex than that for the 8080 (but it doesn't include RIM
or SIM).
-- 
{hplabs,amdahl,3comvax}!bnrmtv!perkins        --Henry Perkins

It is better never to have been born.  But who among us has such luck?
One in a million, perhaps.

ben@catnip.UUCP (01/16/87)

In article <175@herman.UUCP> det@herman.UUCP (Derek Terveer) writes:
>In article <249@rocksanne.UUCP>, stein@rocksanne.UUCP (Adam Stein) writes:
>> I am look for a Z80 to 8080 program converter.  My C compiler only comes with
>> an 8080 assembler.  This is for a TRS-80 Model 4.  I don't care what language
>> it's written in.  I would appreciate any help on this.
>
>I believe that z80 has a mere two instructions that 8080 doesn't have.
>Therefore, most likely, your z80 program will run unchanged with the 8080
>assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
>those two instructions that is)


The Z80 and 8080 use the same op-codes and very nearly compatible (except
for a couple of new instructions on the Z80), but the assembly language
for the two chips is quite different.  I am not sure why Zilog decided
to change the mnemonics (sp?), but they did.

-- 

Ben Broder
{ihnp4,decvax} !hjuxa!catnip!ben
{houxm,clyde}/

zben@umd5 (Ben Cranston) (01/16/87)

In article <707@argus.UUCP> ken@argus.UUCP (Kenneth Ng) writes:
> In article <175@herman.UUCP>, det@herman.UUCP (Derek Terveer) writes:
>> In article <249@rocksanne.UUCP>, stein@rocksanne.UUCP (Adam Stein) writes:
>>> ...Z80 to 8080 program converter.  ...
>> I believe that z80 has a mere two instructions that 8080 doesn't have.
>> Therefore, most likely, your z80 program will run unchanged with the 8080
>> assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
>> those two instructions that is)
> The z80 has a LOT more than 2 more op codes over the 8080.

Ahem.  The 8080's instructions were completely specified by the first byte
of the opcode (the remaining bytes were addresses and such).  The Z80 used
two previously unused values of this first byte for the added instructions, 
but they both involved a SECOND byte to completely specify the additional
instruction.  Thus there could have been as many as 512 added operations.

I don't think there were 512, but I KNOW there were more than two.  Consider
all the instructions that used the IX and IY index registers - they all had
to be added opcodes...

The only fault to this shoehorning of all the new instructions into but two
opcodes was that all the USEFUL instructions took one additional cycle to
execute...

-- 
                    umd5.UUCP    <= {seismo!mimsy,ihnp4!rlgvax}!cvl!umd5!zben
Ben Cranston zben @ umd2.UMD.EDU    Kingdom of Merryland UniSys 1100/92
                    umd2.BITNET     "via HASP with RSCS"

ericr@hpvcla.HP.COM (Eric Ross) (01/17/87)

It is true that the Z80 --> 8080 conversion is typically transparent
except for some items such as index registers, alternate registers,etc.
But, the syntax between the two assemblers is radically different.  
Z80 uses LD, while 8080 uses MOV for instance.

Eric Ross
ihnp4!hpfcla!hpvcla!ericr

janm@runx.OZ (Jan Mikkelsen) (01/17/87)

In article <175@herman.UUCP>, det@herman.UUCP (Derek Terveer) writes:

>I believe that z80 has a mere two instructions that 8080 doesn't have.
>Therefore, most likely, your z80 program will run unchanged with the 8080
>assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
>those two instructions that is)

	The Z80 is object compatible with the 8080, but *not* the other way
around! For examply, the Z80 has two 16 bit index registers, which the 8080
does not have, IX and IY. Now if a compiler is going to ignore two 16 bit
registers, it would not be a very good one. I very much double good Z80 code
could run unmodified on an 8080. Maybe a macro assembler, with macros for the
Z80 instructions in 8080 code?

		Jan Mikkelsen.


ACSnet: janm@runx.oz				JANET:	runx.oz!janm@ukc
ARPA:   janm%runx.oz@seismo.css.gov		CSNET:	janm@runx.oz
UUCP:   {enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!runx.oz!janm

I KNOW there is something I have forgotten .... Of cource! The witty remark!

zeta@runx.OZ (Nick Andrew) (01/18/87)

    
>   I believe that z80 has a mere two instructions that 8080 doesn't have.
>   Therefore, most likely, your z80 program will run unchanged with the 8080
>   assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
>   those two instructions that is)

   Good heavens, protect us from totally uninformed opinions.

   The Z80 contains many improvements on the 8080. Some of these are:

- Relative jumps (8 bit displacement)
- Alternate register set
- Additional Index registers (IX & IY) (one pair)
- Block-statements (block move, block IO)
- Rationalised assembler mnemonics and instruction formats

   If you have a good 8080 macro assembler you could write macros to handle
the conversion (eg change all jump relatives to jump absolutes), but at the
same time there will probably need to be some syntax changes to the Z80
source so it will comply with the requirements of the macro assembler.


   You can mail me at....
ACSnet:    zeta@runx.OZ
UUCP:      ...!{seismo,hplabs,mcvax,ukc,nttlab}!munnari!runx.runx!zeta
UUCP:      ...!{seismo,hplabs,mcvax,ukc,nttlab}!munnari!runx.OZ!zeta
Fidonet:   Nick Andrew@[620/602] (Zeta)   **** NEW NODE NUMBER ****
bbs:       Sysop@zeta, +61 2 627 4177, CCITT V21.
Mail:      P.O Box 177, Riverstone NSW 2765 Australia.

heins@orion.UUCP (Michael Heins) (01/18/87)

In article <175@herman.UUCP> det@herman.UUCP (Derek Terveer) writes:
>In article <249@rocksanne.UUCP>, stein@rocksanne.UUCP (Adam Stein) writes:
>> I am look for a Z80 to 8080 program converter.  My C compiler only comes with
>> an 8080 assembler.  This is for a TRS-80 Model 4.  I don't care what language
>> it's written in.  I would appreciate any help on this.
>
>I believe that z80 has a mere two instructions that 8080 doesn't have.
>Therefore, most likely, your z80 program will run unchanged with the 8080
>assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
>those two instructions that is)

You are thinking of the 8085, not the Z80.  The Z80 has a dozen or so more
instructions than the 8080, and in addition, has nearly twice as many
registers (af, bc, de, and hl are duplicated and bank-switched).  The z80
ISA is a proper superset of the 8080 instructions -- with one exception.  The
z80 uses the parity flag in double duty (parity/overflow).  In practice, this
exception has rarely proved to be a problem.  Normally therefore, programs
compiled/assembled for the 8080 will run fine on the z80, but not the other
way around.

-- 
	...!hplabs!sdcrdcf!trwrb!orion!heins

	We are a way for the universe to know itself. -- Carl Sagan

rlk@chinet.UUCP (Richard Klappal) (01/19/87)

Not withstanding the 250 (+/-) object code combinations of the 8080
and the 796 combos for the Z-80, and (as I understand it) Intel
copyrighted the mnemonics for the 8080, preventing their use
by Zilog,

	The Microsoft M-80 assembler will handle both sets of
	mnemonics, (both in the same program, if desired), or
	check a bulletin board for CP/M to find one of the
	PD Z-80 assemblers (z80asm is one, I believe.) if your
	need doesn't warrant buying one.


I speak for myself only, and have no financial interest in the
success or failure of Microsoft Corp.

-- 
---
UUCP: ..!ihnp4!chinet!uklpl!rlk || MCIMail: rklappal || Compuserve: 74106,1021
      ..

paula@bcsaic.UUCP (01/21/87)

ben@catnip.UUCP (Bennett Broder) writes:

>In article <175@herman.UUCP> det@herman.UUCP (Derek Terveer) writes:
>>In article <249@rocksanne.UUCP>, stein@rocksanne.UUCP (Adam Stein) writes:
>>> I am look for a Z80 to 8080 program converter.  My C compiler only comes with
>>
>>I believe that z80 has a mere two instructions that 8080 doesn't have.
>>Therefore, most likely, your z80 program will run unchanged with the 8080
>>assembler (I hope i'm right in this).  (As long as the z80 code doesn't use
>>those two instructions that is)
>
>The Z80 and 8080 use the same op-codes and very nearly compatible (except
>for a couple of new instructions on the Z80), but the assembly language

Since it's been a while since I looked at my Z80 Tech Ref, I'm not going
to flame anybody for posting without knowing what they're talking about.
But really, guys.  The Z80 has at least twice as many opcodes as the
8080.  Most of the new instructions were bit-manipulation, block move,
and block I/O.  The machine architecture included two new index
registers and a duplicate set of registers for fast context-switching.
There were certainly some other additional features, but I can't
remember them.  The Z80 was intended to be upward-compatible with the
8080.  In fact, most 8080 code will run unchanged on a Z80.  (There was
one problem with the Z flag or something, but I don't remember the
details.)

In response to the original poster, a translator from Z80 to 8080 will
need to output 8080 code to emulate not only the new instructions, but
also the expanded register set.  Probably doable, but not as trivial as
some have suggested.  And no, I don't know where you can get such a
translator.  Sorry.

Paul Allen

-- 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Paul L. Allen                           | "Look out, men! He's armed!"
Boeing Advanced Technology Center       |        "I've got a cheese grater,
POB 24346 M/S 7L-44,                    |        and I'm not afraid to use it!"
Seattle, WA, USA 98124                  | "Don't make it any harder 
(206) 865-3207                          | on yourself, kid! Drop it!"
...!uw-beaver!ssc-vax!bcsaic!paula      |        "Eat mozzarella, copper!"

w8sdz@brl-smoke.UUCP (01/25/87)

There is a public domain Z80 to 8080 source code translator available
from SIMTEL20 as PD:<CPM.ASMUTL>XIZI-3.LBR.  The LBR contains
translators to go in either direction.  No source code for the
translators is provided.  Hint: Watch the "JP" instruction!

To obtain up to five files in a single request message by netmail from
the public domain archives kept on SIMTEL20.ARPA, send a message to:

ARCHIVE-REQUEST@SIMTEL20.ARPA

or via uucp:
   ...!ucbvax!simtel20.arpa!archive-request
   ...!uw-beaver!simtel20.arpa!archive-request
   ...!decwrl!simtel20.arpa!archive-request
   ...!lll-crg!simtel20.arpa!archive-request
   ...!ut-sally!simtel20.arpa!archive-request
   ...!harvard!simtel20.arpa!archive-request

[do NOT use host "seismo" - they are blocking messages from the server]

The message body must contain lines beginning with the keyword SEND,
one SEND line for each file requested.  Case is not significant.

The general syntax of a SEND line is:

SEND format filename

In general, a filename consists of the following components:

device:<directory>file.type.generation

"device:" is usually PD:, and the combination of PD:<directory> is
expected unless an alias has been advertised of the form "alias:",
which takes the place of both device and directory fields.  The
generation field should be left off in order to default to the highest
generation number so you can be sure of getting the latest version of
the file requested.  "file.type" follows the usual filenaming
conventions.

In all formats listed below, if the file to be sent is larger than
55K, the file is sent in numbered parts.  The parts must be
reassembled in order and edited to remove any headers, preface, and
trailers before the process can be reversed to reconstruct the
original file.

Allowable formats are:

SEND HELP
        This file you are reading now.

SEND INFO
        A detailed description of the SIMTEL20 Archives, which
        includes this file, pointers to certain key files, and
        descriptions of various file transfer programs and related
        utilities.

SEND BOOTSTRAP
        A brief quick reference listing of filenames of the key
        utilities used to reconstruct files sent by the compression
        and encoding techniques listed below.

SEND DIR filespec
        This format returns a CRC list of the requested files, and is
        the only format which allows wildcard filenames (but not
        wildcard directory names).  The list is sent as an ASCII text
        file.  The wildcard characters are "*" and "%".  The asterisk
        means any number of characters, while the percent sign means
        exactly one character.  Either or both may appear in any
        combination in either or both the file or type fields, while
        only the asterisk may appear in the generation field.

SEND RAW filename
        If the file is ASCII, it is sent as-is, regardless of size.
        This format is the least efficient over network and mail
        gateway resources.  Use this format only if you absolutely
        must.

With the four formats listed below, if the file is ASCII and under 25k
characters, it is sent as-is, as if RAW format was requested.  Binary
files are always processed according to the requested format.
However, a request for ARC or SQ processing of files with type ".ARC",
".LBR", or ".%Q%" is ignored and the original file is either uuencoded
or hexified (if possible), according to the requested format.  If the
file was not sent RAW, a short preface is inserted at the front of the
message describing the process actually taken and a CRC entry
describing the original file.

SEND ARE filename  or  SEND filename
        The original file is made into a uuencoded ARC file.

SEND ARH filename
        The original file is made into a hexified ARC file if the ARC
        file is under 64K bytes long.  Otherwise, an apology is
        returned instead of the requested file.

SEND SQE filename
        The original file is made into a uuencoded SQueezed file.

SEND SQH filename
        The original file is made into a hexified SQueezed file if the
        Squeezed file is under 64K bytes long.  Otherwise, an apology
        is returned instead of the requested file.

To get started in finding your way around the SIMTEL20 archives, send
a message to the server with the request: SEND INFO

--Keith Petersen
Arpa: W8SDZ@SIMTEL20.ARPA
Uucp: {bellcore,decwrl,harvard,lll-crg,ucbvax,uw-beaver}!simtel20.arpa!w8sdz
GEnie Mail: W8SDZ

dennis@rlgvax.UUCP (Dennis Bednar) (02/04/87)

In article <445@catnip.UUCP>, ben@catnip.UUCP (Bennett Broder) writes:
> In article <175@herman.UUCP> det@herman.UUCP (Derek Terveer) writes:
> >In article <249@rocksanne.UUCP>, stein@rocksanne.UUCP (Adam Stein) writes:
> >> I am look for a Z80 to 8080 program converter.

The Z80 is a superset of the 8080 at the binary code level (that is
a binary 8080 program should run on a Z80, but not the converse, since
the Z80 has at least the IX index register that the 8080 doesn't have,
and hence the Z80 has additional instructions that the 8080 doesn't have).
The source code mneumonics for the older 8080 instructions were not
preserved however.  However, it is pretty easy to "hand-compile" 8080
source code into Z80 source code, once you get the hang of things (I
remember doing this several years ago).  Digression: The Small-C compiler
written by Ron Cain (published in Dr. Dobbs Journal several years ago) was
originally written to output 8080 source code.  It was relatively easy
to change it to output Z80 source code instead.

Therefore, if you plan to convert Z80 source code to 8080 source code,
you will have problems for those Z80 instructions which have no 8080
counterpart.
-- 
FullName:	Dennis Bednar
UUCP:		{seismo|sundc}!rlgvax!dennis
USMail:		CCI; 11490 Commerce Park Dr.; Reston VA 22091
Telephone:	+1 703 648 3300