* 6800 microcomputer to Flexowriter printer driver* transcribed by D Forbes 7/3/2003* original dates from early 1978* was assembled with tiny assembler from Byte magazine* It must have worked; it printed itself out!* Typing rate is 8.0 chars per second open-loop* Uses a PIA chip to talk to the Flexowriter* Data port is DA0-7; bits 0-5 are data, bit 7 is print command* CR and TAB use carriage sensor switch on CA1 pin	org	$6c0**************** Flexowriter **   Typer     **             ** Version 3.0 **             **David Forbes ****************tx1	rmb	2tx2	fcb	5	rmb	1elr	equ	$11case	rmb	1inv	rmb	1brng	equ	$berng	equ	$dpida	equ	$8008	; PIA data port Apica	equ	$8009	; PIA control port Apidb	equ	$800a	; PIA data port Binit	clr	pica	; reset DDR mode bit if on	ldaa	#$ff	; make sure data port is all 1s = no solenoids on	staa	pida	ldab	#4	; select data direction register DDR	stab	pica	staa	pida	; set all bits of port A to output mode	ldaa	#$3a	bsr	tcod	; shift into lower case	clr	case	; duly noted	rtstchr	stx	tx1	cmpa	#$d	; CR does CRLF on machine	bne	nolf	ldaa	#$40	bra	wait	; needs extra waiting timenolf	cmpa	#9	; tab does tab on machine	bne	ntab	ldaa	#$2ewait	bsr	tcod	; put the char out to flexowriter	ldaa	#$40	bsr	del	; wait a while for carriage motion	ldaa	pida	; clear interrupt flags for port awate	ldaa	pica	; wait for interrupt flag from CA1 pin falling	bpl	wate	ldaa	#$50	; wait a bit longer = 125 milliseconds 	bsr	delret	rts		; finally done with tab/CRntab	cmpa	#32	; non-printing - skip	blt	ret	anda	#$7f	suba	#$20	; lookup table starts at space	staa	tx2pl	ldx	tx2	ldaa	0,x	; why didn't I put char in X? inexperience?	ldx	tx1	psha	bita	#$40	; test shift case dependence of char	bne	prop	; no need to shift	anda	#$80	; test case against current shift case	eora	case	bpl	prop	; in proper case already	tst	case	beq	uppr	ldaa	#$3a	; shift down	bra	outcuppr	ldaa	#$3c	; shift upoutc	bsr	tcod	; do it	com	caseprop	pula	anda	#$3f	; throw away case bits of BCDIC char - also turns on 			; print clutch in bit 7tcod	coma		; invert to match active-low solenoid driver logic	staa	pida	; put char out to PIA data port A	ldaa	#32	bsr	del	; wait for 32 units = 50 milliseconds	ldaa	#$7f	staa	pida	; turn off code solenoids but leave print clutch on	ldaa	#32	bsr	del	; wait 32 more units = 50 milliseconds	ldaa	#$ff	staa	pida	; turn off print clutch		ldaa	#16	; wait 16 more units = 25 millisecondsdel	clrbdlp	decb		; 6 microseconds * 256 iterations = 1.536 milliseconds	bne	dlp	deca		; plus 8 for outer loop = 1.544 milliseconds total	bne	del	rts
