; Z80 to 8086 Translator  version 2.0
;  Runs on the Z80 under CP/M
; by Tim Paterson
;
	ORG	100H
EOF:	EQU	1AH	;End of file
EOL:	EQU	0DH
FCB:	EQU	5CH
SYSTEM:	EQU	5
OPEN:	EQU	15
CLOSE:	EQU	16
SETDMA:	EQU	26
CREATE:	EQU	22
DELETE:	EQU	19
READ:	EQU	20
WRITE:	EQU	21
PRNBUF:	EQU	9
	LD	SP,STACK
	LD	DE,HEADER
	LD	C,9
	CALL	SYSTEM
	LD	HL,FCB+12
	XOR	A
	LD	B,4
CLRFCB:
	LD	(HL),A
	INC	HL
	DJNZ	CLRFCB
	LD	(FCB+32),A
	LD	HL,FCB
	LD	DE,PUTFCB
	LD	BC,16
	LDIR
	LD	(PUTFCB+32),A
	LD	HL,'A'+3800H	;"A8"
	LD	(PUTFCB+9),HL
	LD	A,'6'
	LD	(PUTFCB+11),A
	LD	DE,FCB
	LD	C,OPEN
	CALL	SYSTEM
	INC	A
	LD	DE,NOFILE
	JR	Z,ABORTJ
	LD	DE,PUTFCB
	LD	C,DELETE
	CALL	SYSTEM
	LD	DE,PUTFCB
	LD	C,CREATE
	CALL	SYSTEM
	INC	A
	LD	DE,NOROOM
ABORTJ:
	JR	Z,ABORT
	LD	DE,PUTFCB
	LD	C,OPEN
	CALL	SYSTEM
	LD	HL,PUTBUF
	LD	(PUTPT),HL
	LD	HL,GETBUF+80H
	LD	(GETPT),HL
TRANLN:
	XOR	A
	LD	(OP1),A
	LD	(OP2),A
	LD	HL,OPCODE
	CALL	LOAD
	LD	HL,OP1
	CALL	GETOP
	LD	(HL),0
	LD	HL,OP2
	CALL	GETOP
DOLIN:
	LD	(HL),0
	CALL	FINDOP
ENLIN:
	LD	SP,STACK
	LD	A,(CHAR)
	CP	';'
	JR	NZ,NOCOM
	LD	A,9
	CALL	PUTCH
	LD	A,';'
NOCOM:
	CALL	PUTCH
PUTLIN:
	CP	EOF
	JR	Z,END
	CALL	GETCH
	CALL	PUTCH
	CP	10
	JR	NZ,PUTLIN
	JR	TRANLN
END:
	LD	B,127
	LD	A,1AH
FILL:
	CALL	PUTCH
	DJNZ	FILL
	LD	DE,PUTFCB
	LD	C,CLOSE
	CALL	SYSTEM
	LD	DE,ENDMES
ABORT:
	LD	C,PRNBUF
	CALL	SYSTEM
	JP	0
DELIM:
	CALL	GETCH
DELCHK:
	CP	EOL
	JR	Z,DOLIN
	CP	EOF
	JR	Z,DOLIN
	CP	';'
	JR	Z,DOLIN
	CP	' '
	RET	Z
	CP	':'
	RET	Z
	CP	','
	RET	Z
	CP	9
	RET
HEX:
	AND	0FH
	ADD	A,90H
	DAA
	ADC	A,40H
	DAA
PUTCH:
	PUSH	HL
	PUSH	DE
	PUSH	BC
	PUSH	AF
	AND	7FH
	LD	HL,(PUTPT)
	LD	(HL),A
	INC	HL
	LD	(PUTPT),HL
	PUSH	DE
	PUSH	HL
	LD	DE,PUTBUF+80H
	OR	A
	SBC	HL,DE
	POP	HL
	POP	DE
	JR	NZ,POPRET
	LD	DE,PUTBUF
	LD	(PUTPT),DE
	LD	C,SETDMA
	CALL	SYSTEM
	LD	DE,PUTFCB
	LD	C,WRITE
	CALL	SYSTEM
	OR	A
	LD	DE,WRTERR
	JR	NZ,ABORT
POPRET:
	POP	AF
NOTAF:
	POP	BC
	POP	DE
	POP	HL
	RET
;
; Get character from source file.
;
GETCH:
	PUSH	HL
	PUSH	DE
	PUSH	BC
	LD	HL,(GETPT)	; Get buffer pointer.
	PUSH	DE
	PUSH	HL
	LD	DE,GETBUF+80H
	OR	A
	SBC	HL,DE		; Past end-of-buffer?
	POP	HL
	POP	DE
	JR	NZ,GETIT	; Jump if not.
	LD	DE,GETBUF	; Set `DMA address'.
	LD	C,SETDMA
	CALL	SYSTEM
	LD	DE,FCB	; Read the next record from source file.
	LD	C,READ
	CALL	SYSTEM
	OR	A	; Entire record read OK?
	LD	A,EOF	; Force end-of-file character in case
	JR	NZ,TESEND	;  there is nothing in the record.
	LD	HL,GETBUF	; Reset buffer pointer.
GETIT:
	LD	A,(HL)	; Get next character from buffer.
	INC	HL	; Point to next character.
	LD	(GETPT),HL	; Save new pointer.
TESEND:
	LD	(CHAR),A
	JR	NOTAF	; Pop registers and return.
LOAD:
	CALL	DELIM
	JR	Z,LOADOP
EATLAB:
	CALL	PUTCH
	CALL	DELIM
	JR	NZ,EATLAB
ENLAB:
	LD	A,':'
	CALL	PUTCH
LOADOP:
	LD	HL,OPCODE
EATEM:
	CALL	DELIM
	JR	Z,EATEM
LOADLP:
	CALL	IDCHK
	JP	C,OPERR
	LD	(HL),A
	INC	HL
	CALL	DELIM
	JR	NZ,LOADLP
	LD	(HL),0
	CP	':'
	RET	NZ
	LD	HL,OPCODE
	CALL	TRANS
	JR	ENLAB
GETOP:
	XOR	A
	EX	AF,AF'
GETLP:
	CALL	DELIM
	JR	Z,GETLP
OPCHAR:
	CP	'('
	JR	NZ,NOTLEF
	EX	AF,AF'
	INC	A
	EX	AF,AF'
	LD	(HL),'['
	JR	NEXCH
NOTLEF:
	CP	')'
	JR	NZ,NOTRIT
	EX	AF,AF'
	DEC	A
	EX	AF,AF'
	LD	(HL),']'
	JR	NEXCH
NOTRIT:
	LD	(HL),A
	CP	''''
	JR	Z,EATQUO
	CALL	IDCHK
	JR	NC,GETID
NEXCH:
	INC	HL
	CALL	GETCH
IDRET:
	CALL	DELCHK
	JR	NZ,OPCHAR
	CP	' '
	JR	Z,OPCHAR
	RET
EATQUO:
	INC	HL
	CALL	GETCH
	LD	(HL),A
	CP	';'
	CALL	NZ,DELCHK
	CP	''''
	JR	NZ,EATQUO
	JR	NEXCH
IDCHK:
	CP	'0'
	RET	C
	CP	'9'+1
	CCF
	RET	NC
	CP	40H
	RET	C
	AND	5FH
	CP	'A'
	RET	C
	CP	'Z'+1
	CCF
	RET
GETID:
	LD	(HL),A
	LD	B,1
LODID:
	INC	HL
	CALL	GETCH
	CALL	IDCHK
	JR	C,RWCHK
	LD	(HL),A
	INC	B
	JR	LODID
RWCHK:
	PUSH	AF
	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Z	LOOKLP
	LD	E,(HL)
	INC	HL
	LD	D,(HL)
	INC	HL
	PUSH	DE
	LD	E,(HL)
	INC	HL
	LD	D,(HL)
	LD	H,D
	LD	L,E
	POP	DE
	PUSH	DE
	POP	IX
	JP	(IX)
NEXOP:
	BIT	7,(HL)
	INC	HL
	JR	Z,NEXOP
	LD	DE,4
	ADD	HL,DE
	JR	LOOKOP
OPERR:
	LD	HL,OPCODE
	CALL	OUTSTR
	CALL	TWOOPS
	LD	HL,OPCDER
	CALL	OUTSTR
	JP	ENLIN
LD:
	CALL	OUTSTR
	LD	HL,OP1
	LD	DE,OP2+1
	CALL	LCHECK
	JP	Z,LDAX
	EX	DE,HL
	DEC	HL
	INC	DE
	CALL	LCHECK
	JP	Z,STAX
;If immediate move, check for byte memory reference
	LD	A,(OP1)
	CP	'['	;Memory reference?
	JR	NZ,TWOOPS
	LD	A,(OP1+1)	;Referencing IX as a word?
	CP	RIX
	JR	Z,TWOOPS
	CP	RIY
	JR	Z,TWOOPS
	LD	A,(OP2)
	CP	20H	;Could be immediate?
	LD	A,9
	CALL	NC,BFLAG	;Add "B,"
	CALL	TRAN1
	JR	TRNOP2
TWOOPS:
	CALL	TRNOP1
TRNOP2:
	LD	A,','
TRAN2:
	LD	HL,OP2
PTRANS:
	CALL	PUTCH
TRANS:
	LD	A,(HL)
	INC	HL
	OR	A
	RET	Z
	CALL	TRNTOK
	JR	TRANS
LCHECK:
	LD	A,(HL)
	CP	RAL
	RET	NZ
	LD	A,(DE)
	CP	RCX
	RET	Z
	CP	RDX
	RET

ONEOP:
	CALL	OUTSTR

TRNOP1:
	LD	A,9
TRAN1:
	LD	HL,OP1
	JR	PTRANS
IN:
	LD	A,(OP1)
	CP	RAL
	EX	DE,HL
	LD	HL,OP2
	JR	Z,GETPORT
	LD	HL,SAVEAX
	CALL	OUTSTR
	CALL	OUTSTR
	LD	HL,OP2
	CALL	GETPORT
	LD	HL,MOV0
	CALL	ONEOP
	LD	A,','
	CALL	PUTCH
	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MOVE:	DB	0,'MOV',9,'SI,BX',0,'MOV',9,'DI,DX'
	DB	0,'REP',0,'MOVB',0,'MOV',9,'DX,DI'
	DM	0,'MOV',9,'BX,SI'
CPIR:	DB	'UP'
CMPREP:	DB	0,'MOV',9,'DI,BX',0,'REPNZ',0,'SCAB'
	DM	0,'MOV',9,'BX,DI'
DAD1:	DM	'LAHF',0,'ADD'
DAD2:	DM	0,'RCR',9,'SI',0,'SAHF',0,'RCL',9,'SI'
LAHF:	DM	'LAHF'
	DM	0,'SAHF'
DJNZ:	DB	'DEC',9,'CH',13,10
	DB	'; *** WARNING: DJNZ does not affect flags - DEC does.',0
	DM	'JNZ'
WARNPA:	DM	13,10,'; *** WARNING: Parity flag not always same as Z80.'
IO1:	DB	'MOV',9,'DI,DX',0,'MOV',9,'DL,CL',0
	DM	'XOR',9,'DH,DH',13,10,9
IO2:	DM	0,'MOV',9,'DX,DI'
BADIO:	DM	13,10,'; *** WARNING: Flags not same as Z80.'
BITERR:	DM	13,10,' *** ERROR: Cannot determine bit number.'
SETBIT:	DM	'LAHF',0,'OR'
	DM	0,'SAHF'
RESBIT:	DM	'LAHF',0,'AND'
	DM	0,'SAHF'
TESBIT:	DM	'RCR',9,'SI',0,'TEST'
	DM	0,'RCL',9,'SI'
XTHL1:	DM	'POP',9,'SI',0,'XCHG',9,'SI'
XTHL2:	DM	0,'PUSH',9,'SI'
EXX:	DB	'XCHG',9,'BX,[HL]',0,'XCHG',9,'DX,[DE]',0
	DM	'XCHG',9,'CX,[BC]'
EXAF:	DM	'LAHF',0,'XCHG',9,'AX,BP',0,'SAHF'
MOVAL:	DM	0,'MOV',9,'AL'
IXSI:	DM	9,'MOV',9,'SI,[IX]',13,10
IYDI:	DM	9,'MOV',9,'DI,[IY]',13,10
RESTAX:	DB	0
SAVEAX:	DM	'XCHG',9,'AX,SI'
CRLFTB:	DM	13,10,9
INB:	DM	'INB',9
OUTB:	DM	'OUTB',9
XCHG:	DM	'XCHG'
JMP:	DM	'JMP'
JR:	DM	'JP'
RCL:	DM	'RCL'
RCR:	DM	'RCR'
ROL:	DM	'ROL'
ROR:	DM	'ROR'
SAL:	DM	'SAL'
SAR:	DM	'SAR'
SHR:	DM	'SHR'
STC:	DM	'STC'
IRET:	DM	'IRET'
HLT:	DM	'HLT'
CMC:	DM	'CMC'
NOT:	DM	'NOT'
MOV0:	DB	0
MOV:	DM	'MOV'
CMP:	DM	'CMP'
SBB:	DM	'SBB'
CALL:	DM	'CALL'
TOKTAB:
	DB	'SIDI'
	DB	'PEPOS',0,'NSNZZ',0,'NCC',0
	DB	'AXSPBXDXCX'
	DB	'BLBHDLDHCLCHALIXIY'
RWTAB:
	DB	'ABCDEHLBDHSACNZNPMPPII'
LENRW:	EQU	$-RWTAB
	DB	0,0,0,0,0,0,0,'CELPF',0,'C',0,'Z',0,0,'OEYX'
HEADER:	DB	13,10,'Z80 to 8086 Translator  version 2.0',13,10,'$'
NOROOM:	DB	13,10,'Insufficient directory space to create file',13,10,'$'
NOFILE:	DB	13,10,'File not found',13,10,'$'
ENDMES:	DB	13,10,'Translation complete',13,10,'$'
WRTERR:	DB	13,10,'Out of disk space',13,10,'$'
OPCDER:	DM	13,10,'*** Opcode Error '
CRLF:	DM	13,10
LABEL:	DB	'L0000',0
	DM	':',9
PUTPT:	DS	2
GETPT:	DS	2
CHAR:	DS	1
	DB	0
OPCODE:	DS	80
OP1:	DS	80
OP2:	DS	80
PUTBUF:	DS	128
GETBUF:	DS	128
PUTFCB:	DS	33
	DS	50
STACK:	EQU	$
	ORG	1	;This is really just for equates without EQU
RSI:	DS	1
RDI:	DS	1
ODDPAR:	DS	1
EVEPAR:	DS	1
	DS	5	;MINUS,PLUS,NOT ZERO,ZERO,NOT CARRY
CY:	DS	1
RAX:	DS	1
STP:	DS	1
RBX:	DS	1
RDX:	DS	1
RCX:	DS	1
RBL:	DS	1
RBH:	DS	1
RDL:	DS	1
RDH:	DS	1
RGCL:	DS	1
RCH:	DS	1
RAL:	DS	1
RIX:	DS	1
RIY:	DS	1
