; SIMPLE PORT-TO-PORT TRANSFER WITHOUT BUFFER.
; VERSION 1.0 BY MARTIN EBERHARD 19 JANUARY 2011
; THIS PROGRAM ASSUMES PORT 1 IS ALWAYS READY

A0CTRL	EQU	10H	;ACIA 0 CONTROL OUTPUT PORT
A0STAT	EQU	10H	;ACIA 0 STATUS INPUT PORT
A0TDR	EQU	11H	;ACIA 0 TRANSMIT DATA REGISTER
A0RDR	EQU	11H	;ACIA 0 RECEIVE DATA REGISTER
A1CTRL	EQU	12H	;ACIA 1 CONTROL OUTPUT PORT
A1STAT	EQU	12H	;ACIA 1 STATUS INPUT PORT
A1TDR	EQU	13H	;ACIA 1 TRANSMIT DATA REGISTER
A1RDR	EQU	13H	;ACIA 1 RECEIVE DATA REGISTER

; CONTROL REGISTER BITS

ACCDS1	EQU	00000001B	;COUNTER DIVIDE SELECT 1
ACCDS2	EQU	00000010B	;COUNTER DIVIDE SELECT 2
ACWS1	EQU	00000100B	;WORD SELECT 1
ACWS2	EQU	00001000B	;WORD SELECT 2
ACWS3	EQU	00010000B	;WORD SELECT 3
ACTC1	EQU	00100000B	;TRANSMIT CONTROL 1
ACTC2	EQU	01000000B	;TRANSMIT CONTROL 2
ACRXIE	EQU	10000000B	;RECEIVE INTERRRUPT ENABLE

ACRSET	EQU	00000011B	;MASTER RESET

;COMPOUND COMMANDS
AC0INIT	EQU	ACCDS1+ACWS3	;/16 CLOCK, 8 BITS+2 STOP BITS
AC0REN	EQU	AC0INIT+ACTC2	;MAKES RTS ACTIVE
AC1INIT	EQU	ACCDS1+ACWS1+ACWS3 ;/16 CLOCK, 8 BITS+1 STOP BIT
AC1CTS	EQU	AC1INIT+ACTC2	;MAKES RTS INACTIVE

; STATUS REGISTER BITS

ASRDRF	EQU	00000001B	;RECEIVE DATA REGISTER FULL
ASTDRE	EQU	00000010B	;TRANSMIT DATA REGISTER EMPTY
ASDCD	EQU	00000100B	;DATA CARRIER DETECT
ASCTS	EQU	00001000B	;CLEAR TO SEND
ASFE	EQU	00010000B	;FRAMING ERROR
ASOVRN	EQU	00100000B	;RECEIVER OVERRUN ERROR
ASPE	EQU	01000000B	;PARITY ERROR
ASIRQ	EQU	10000000B	;INTERRUPT REQUEST


ORG 0

; INITIALIZE BOTH ACIAS

	MVI	A,ACRSET
	OUT	A0CTRL
	OUT	A1CTRL

	MVI	A,AC0INIT
	OUT	A0CTRL
	MVI	A,AC1INIT	;ENABLE RS232
	OUT	A1CTRL

LEADER:	IN	A0STAT
	RAR			;TEST RDR FULL
	JNC	LEADER		;WAIT FOR PAPER TAPE CHR

	IN	A0RDR		;GET TAPE BYTE
	ORA	A		;IGNORE LEADING NULLS
	JZ	LEADER


MAIN:	OUT	A1TDR		;SEND IT DIRECTLY TO RS232 PORT

GETCHR:	IN	A0STAT
	RAR			;TEST RDR FULL
	JNC	GETCHR		;WAIT FOR PAPER TAPE CHR

	IN	A0RDR		;GET PAPER TAPE BYTE

	JMP	MAIN

END