* PRINT.SYS for serial printer

ACIA	equ	$F006		;Altair 680 UIO serial port

SIOCSR	equ	ACIA		;control/status register
SIODR	equ	ACIA+1
TDRE	equ	$02		;transmit ready

* Printer initialization at $ACC0

	org	$ACC0

	ldaa	#$03		;reset ACIA
	staa	SIOCSR
	ldaa	#$15		;8N1
	staa	SIOCSR
	rts

* Check for printer ready at $ACD8. Return minus TRUE if ready

	org	$ACD8

	pshb			;can't change B
	ldab	SIOCSR		
	rorb			;move TDRE bit 2 to bit 7
	rorb
	rorb
	pulb			;restore b
	rts

* Output character from A at $ACE4.

	org	$ACE4

	pshb			;can't change B
	
prtWait	ldab	SIOCSR		;wait for TDRE asserted
	andb	#TDRE
	beq	prtWait

	pulb			;restore b
	staa	SIODR		;output the byte
	rts

	end
