UX80(1)

NAME
ux80 - translate Intel 8080 assembly to Zilog Z80 assembly

SYNOPSIS
ux80 [-v] [-o output.mac] input.mac

DESCRIPTION
ux80 is a source-to-source translator that converts Intel 8080 assembly language to Zilog Z80 assembly language. The translated code assembles to an identical binary as the original 8080 source when processed by an assembler that supports both instruction sets.

The translator:

•   Converts all 8080 mnemonics to their Z80 equivalents

•   Preserves all comments, labels, macros, and formatting

•   Passes through assembler directives unchanged

•   Automatically adds a .Z80 directive at the start of the output

•   Handles both single-colon (:) and double-colon (::) label syntax

The output is designed to be assembled with um80(1) or any compatible Z80 assembler.

OPTIONS

-v, --version
    Display version information and exit.

-o output.mac
    Specify the output file name. If not specified, the output file is named by appending _z80 before the extension of the input file (e.g., program.mac becomes program_z80.mac).

-h, --help
    Show usage information and exit.

INSTRUCTION TRANSLATION

  Data Movement
8080 | Z80 | Description
MOV r,r' | LD r,r' | Register to register
MOV r,M | LD r,(HL) | Memory to register
MOV M,r | LD (HL),r | Register to memory
MVI r,n | LD r,n | Immediate to register
MVI M,n | LD (HL),n | Immediate to memory
LXI rp,nn | LD rp,nn | Immediate to register pair
LDA addr | LD A,(addr) | Direct load accumulator
STA addr | LD (addr),A | Direct store accumulator
LHLD addr | LD HL,(addr) | Direct load HL
SHLD addr | LD (addr),HL | Direct store HL
LDAX rp | LD A,(rp) | Indirect load (BC/DE)
STAX rp | LD (rp),A | Indirect store (BC/DE)
XCHG | EX DE,HL | Exchange DE and HL
XTHL | EX (SP),HL | Exchange HL with stack top
SPHL | LD SP,HL | Load SP from HL

  Arithmetic and Logic
8080 | Z80 | Description
ADD r | ADD r | Add register to A
ADC r | ADC r | Add with carry
SUB r | SUB r | Subtract register from A
SBB r | SBC r | Subtract with borrow
ANA r | AND r | AND register with A
XRA r | XOR r | XOR register with A
ORA r | OR r | OR register with A
CMP r | CP r | Compare register with A
ADI n | ADD n | Add immediate
ACI n | ADC n | Add immediate with carry
SUI n | SUB n | Subtract immediate
SBI n | SBC n | Subtract immediate with borrow
ANI n | AND n | AND immediate
XRI n | XOR n | XOR immediate
ORI n | OR n | OR immediate
CPI n | CP n | Compare immediate
INR r | INC r | Increment register
DCR r | DEC r | Decrement register
INX rp | INC rp | Increment register pair
DCX rp | DEC rp | Decrement register pair
DAD rp | ADD HL,rp | Add register pair to HL
DAA | DAA | Decimal adjust A

  Rotate and Complement
8080 | Z80 | Description
RLC | RLCA | Rotate A left
RRC | RRCA | Rotate A right
RAL | RLA | Rotate A left through carry
RAR | RRA | Rotate A right through carry
CMA | CPL | Complement A
STC | SCF | Set carry flag
CMC | CCF | Complement carry flag

  Branching
8080 | Z80 | Description
JMP addr | JP addr | Jump unconditional
JNZ addr | JP NZ,addr | Jump if not zero
JZ addr | JP Z,addr | Jump if zero
JNC addr | JP NC,addr | Jump if no carry
JC addr | JP C,addr | Jump if carry
JPO addr | JP PO,addr | Jump if parity odd
JPE addr | JP PE,addr | Jump if parity even
JP addr | JP P,addr | Jump if positive
JM addr | JP M,addr | Jump if minus
PCHL | JP (HL) | Jump to address in HL

  Subroutines
8080 | Z80 | Description
CALL addr | CALL addr | Call unconditional
CNZ addr | CALL NZ,addr | Call if not zero
CZ addr | CALL Z,addr | Call if zero
CNC addr | CALL NC,addr | Call if no carry
CC addr | CALL C,addr | Call if carry
CPO addr | CALL PO,addr | Call if parity odd
CPE addr | CALL PE,addr | Call if parity even
CP addr | CALL P,addr | Call if positive
CM addr | CALL M,addr | Call if minus
RET | RET | Return unconditional
RNZ | RET NZ | Return if not zero
RZ | RET Z | Return if zero
RNC | RET NC | Return if no carry
RC | RET C | Return if carry
RPO | RET PO | Return if parity odd
RPE | RET PE | Return if parity even
RP | RET P | Return if positive
RM | RET M | Return if minus
RST n | RST n | Restart (software interrupt)

  Stack and I/O
8080 | Z80 | Description
PUSH rp | PUSH rp | Push register pair
POP rp | POP rp | Pop register pair
IN port | IN A,(port) | Input from port to A
OUT port | OUT (port),A | Output A to port

  Miscellaneous
8080 | Z80 | Description
NOP | NOP | No operation
HLT | HALT | Halt processor
DI | DI | Disable interrupts
EI | EI | Enable interrupts

  Register Names
8080 | Z80 | Description
M | (HL) | Memory addressed by HL
PSW | AF | Accumulator and flags pair
B | BC | B register pair (also B alone)
D | DE | D register pair (also D alone)
H | HL | H register pair (also H alone)

DIRECTIVES
Assembler directives are passed through unchanged. This includes:

•   ORG, END, EQU, SET, DEFL

•   DB, DW, DS, DC, DA

•   CSEG, DSEG, ASEG, COMMON

•   PUBLIC, EXTRN, EXTERN

•   IF, ELSE, ENDIF, IFDEF, IFNDEF

•   MACRO, ENDM, LOCAL, REPT, IRP, IRPC

•   INCLUDE, INCBIN

•   TITLE, SUBTTL, PAGE, .SALL, .LALL, .XALL

•

A .Z80 directive is automatically added at the beginning of the output file if not already present in the input.

EXAMPLES

Basic translation:
    ux80 program.mac

    Creates program_z80.mac with Z80 mnemonics.

Custom output file:
    ux80 -o z80_version.mac program.mac

Translate and assemble:
    ux80 program.mac
    um80 program_z80.mac
    ul80 program_z80.rel

ROUND-TRIP VERIFICATION
To verify that the translation produces identical binaries:

    # Assemble original 8080 source
    um80 program.mac
    ul80 -o orig.com program.rel
    # Translate and assemble
    ux80 program.mac
    um80 program_z80.mac
    ul80 -o z80.com program_z80.rel
    # Compare binaries
    cmp orig.com z80.com && echo "Identical!"

NOTES

  Why Translate?

•   Z80 mnemonics are often considered more readable and consistent

•   Enables use of Z80-specific tools and assemblers

•   Facilitates mixing translated code with new Z80-native code

•   Some assemblers only support Z80 syntax

  Limitations

•   Z80-only instructions (IX, IY, block moves, etc.) must be added manually

•   The translator does not optimize for Z80-specific features

•   Code that was specifically written for 8080 timing may need adjustment

  SET Directive
The 8080 SET assembler directive (reassignable equate) is preserved in the output. In Z80 mode, the assembler distinguishes between the SET directive (which has a label) and the Z80 SET instruction (which sets a bit in a register and has no label).

EXIT STATUS

0   Translation successful.

1   Error occurred (file not found, syntax error, etc.).

FILES

input.mac
    Input 8080 assembly source file.

output.mac
    Output Z80 assembly source file.

SEE ALSO
um80(1), ul80(1), ud80(1), ulib80(1), ucref80(1)

HISTORY
ux80 was created as part of the um80 toolchain to facilitate working with legacy 8080 assembly code in Z80-based projects. The 8080 and Z80 processors share the same basic instruction set, but use different assembly language syntax.

AUTHOR
um80 project contributors.