Dann bist du am schreiben einer Software-UART ?

Ich hab da mal was aus meinem Historischen Museum.
Ist für einen 8080 ASM - sollte aber mit ein wenig Mühe auf Z80_ASM umzubauen sein.
Code:
; Dokumentation zum Speakeasy I/O Board von George Morrow Mikro Stuff
;
;
;	THE SERIAL DATA INPUT ROUTINE WITH READER CONTROL AND ECHO OPTIONS:
;	Aufrufbedingungen:
;	(A) 	Die Speicherstelle SCON muss auf den richtigen wert ge-
;		setzt sein, vorzugsweise unter Benutzung der unten beschrie-
;		benen DETCT-Routine. Dies ist notwendig, damit die Länge
;		einer Bitzelle, wie sie von der Routine erwartet wird, mit
;		der Länge der Bitzelle der an das Interface angeschlossenen
;		Einheit übereinstimmt.
;	(B)	Register B dient als Optionsregister.
;		1. Ist Bit 0 eine Eins, so werden Echos an den Drucker
;		unterdrückt; anderfalls werden die Zeichen sofort nach
;		vollständiger Übernahme der zugehörigen Bits ausgedruckt.
;		2. Ist Bit 7 eine Eins, so wird ein eventuell am Interface
;		angeschlossener Lochstreifenleser eingeschaltet bis
;		ein Startbit auftritt und dann abgeschaltet.
;	(C)	Die Routine kehrt mit dem empfangenen Datenwort in Register
;		D in das übergeordnete Programm zurück.

816f	78		INPUT	MOV A,B		;Conditionally -
8170	07			RLC		;Turn ON -
8171	D3 06			OUT READR	;the paper tape reader.
8173	2A F3 83		LHLD SCON	;Get The Speed Constant -
8176	E5		SWAIT	PUSH H		;and save on the stack.
8177	1E FF			MVI E,-1	;initialize the shift reg
8179	DB 05		SLOOK	IN SERAL	;get the input data -
817b	1F			RAR		;and test it -
817c	da 79 81		jc slook	;for a start bit.
817f	cd a0 81		call delay	;wait half a -
8182	e1			pop h		;bit time -
8183	db 05			in seral	;and verify -
8185	if			rar		;that a start -
8186	da 76 81		jc swait	;bit is present.
8189	16 ff			mvi d,-1	;initialize other of shift reg
818b	af			xra a		;stop the -
818c	d3 06			out readr	;reader.
818b	e5		GTBIT	push h		;update the stack
818f	29			dad h		;calculate the speed -
8190	2b			dcx h		;constant for a full bit time.
8191	db 05			in seral	;get the input
8193	5f			mov e,a		;update the shift reg
8194	cd a0 81		call delay	;delay 1 bit time and shift d-e
8197	e1			pop h		;get the speed constant
8198	da 8e 81		jc gtbit	;was the start bit shifted to carry?
819b	3e 01			mvi a,1		;yes. leave with the -
819d	d3 05			out seral	;printer in the space made.
819f	c9			ret
;
;	Serial delay routine used in conjunction with the
;	serial input and output rotines.
;	calling conventions:
;	(A)	H-L is initialized with a value which
;		determines the time before the routine
;		returns to the calling program given
;		by 53(H-L) + 58 machine cycles.
;	(B)	Bits 0 of registers B and E are
;		initialized to values consistent with
;		these bits being ored together and
;		to the serial output device.
;	all timings assumed 1 wait state per fetch.
81a0	7b		DELAY	mov a,e		;conditionaly -
81a1	b0			ora b		;output bit 0 of e -
81a2	d3 05			out seral	;to the serial device.
81a4	2b			dcx h		;decrement -
81a5	7c			mov a,h		;the h-l pair -
81a6	b5			ora l		;and test -
81a7	c2 a0 81		jnz delay	;for zero
81aa	7a			mov a,d		;rotate d-e -
81ab	1f			rar		;one -
81ac	7b			mov a,e		;bit -
81ad	1f			rar		;position -
81ae	5f			mov e,a		;to the -
81af	7a			mov a,d		;right -
81b0	1f			rar		;with end around -
81b1	57			mov d,a		;bit preserved.
81b2	c9			ret

;	Serial output routine.
;	Calling conventions:
;	(A)	reg a is initialized to an 8-bit value
;		to be serially sent to the serial output device.
;	(B)	the on-board ram location SCON (serial
;		speed constant) must be initialized to
;		the proper value preferable using the
;		DETCT routine below. this is so that
;		the cell time assumed by the routine and
;		the cell time for the device connected
;		to the interface are compatible.
;	The routine starts by sending a zero for one cell
;	time to the serial device connected to the interface.
;	it next sends bit 0 of reg a, followd by bits
;	1 through 7. it then sends a one for two cell times
;	as rest bit and returns to the calling program.
;	all timing assumes 1 wait state per fetch.
;	including the return address of the calling program,
;	4 levels of the stack are used by the routine.
;	
;	Register Map:
;	A:	Serial Output Data.
;	B:	The Routine loads B with 2(A) to force
;		output when the delay routine is called.
;	C:	used as a bit counter and inittialized
;		to 11 decimal.
;	DE:	16-bit storage shift register for output
;		to the serial output device.
;	HL:	delay time count.

81b3	87		SROUT	add a		;add a start bit
81b4	47			mov b,a		;make bit 0 of b a zero
81b5	5f			mov e,a		;shifted data to e
81b6	3e 0b			mvi a,11	;this is the bit count & the rest bits
81b8	4f			mov c,a		;count to reg c
81b9	17			ral		;load d with the rest -
81ba	57			mov d,a		;bits and high order data bit.
81bb	2a f3 83	OLOOP	lhld SCON	;get the speed constant
81be	2a f3 83		lhld SCON	;padding
81c1	29			dad h		;adjust for output -
81c2	2b			dcx h		;loop.
81c3	cd a0 81		call delay	;output data bit and shift
81c6	0d			dcr c		;decrement bit count
81c7	c2 bb 81		jnz OLOOP
81ca	c9			ret

;	Serial Device Speed Detection Routine:
; Diese Routine sollte benutzt werden wenn das Gesamtsystem ein-
; geschaltet wird. Die benutzte serielle Eingabeeinheit sollte an
; das Interface angeschlossen sein. Die serielle Einheit ist dann ein-
; zuschalten und danach die Routine zu starten.
; Dann sollte der Benutzer die Wagenrücklauftaste (return, carriage return)
; betätigen. Die DETCT-Routine erwartet den Empfang dieses ASCII-Zeichens 
; und kann damit die Baudrate der Einheit messen und den Speicherplatz SCON setzen.
; Die Routine bleibt dann auf dem dynamischen Halt stehen.

81cb	31 e0 83		lxi sp,83e0h	;initialize the stack pointer
81ce	16 06		DETCT	mvi d,6		;transition counter
81d0	4a			mov c,d		;bit 0 of c is -
81d1	0c		TLOOP	inr c		;the important bit here.
81d2	21 01 00		lxi h,1		;offset for hl
81d5	db 05		GETIN	in SERAL	;get the input
81d7	d3 05			out SERAL	;echo
81d9	a9			xra c		;compare with bit 0 of c
81da	1f			rar
81db	23			inx h
81dc	d2 d5 81		jnc GETIN	;wait if no transition
81df	e5			push h		;save the delay time
81e0	15			dcr d
81e1	c2 d1 81		jnz TLOOP
81e4	e1			pop h		;get the 3 zero bits time
81e5	e1			pop h		;get the 2 one bits time
81e6	c1			pop b		;get the 1 zero bit time
81e7	09			dad b		;add together
81e8	c1			pop b		;get the 1 one bit time
81e9	09			dad b		;add to previous subtotal
81ea	c1			pop b		;discard the start bit -
81eb	c1			pop b		;and the infinite string -
81ec	16 03			mvi d,3		;of rest bits.
81ee	af		SLOOP	xra a		;divide -
81ef	7c			mov a,h		;the -
81f0	1f			rar		;total -
81f1	67			mov h,a		;by -
81f2	7d			mov a,l		;eight -
81f3	1f			rar		;to -
81f4	8f			mov l,a		;calculate -
81f5	15			dcr d		;half the -
81f6	c2 ee 81		jnz SLOOP	;data bit time -
81f9	2b			dcx h		;adjust for other -
81fa	22 f3 83		shld SCON	;routines and save.
81fd	c3 fd 81	STOP	jmp STOP	; dynamic halt

; 1975 - Bill Godbout and George Morrow (who would later build the Morrow Computer) 
; build the first 16-bit computer with RAM and a built-in cassette interface.
; An advertisement for the unnamed computer appears in the first issue 
; of Byte Magazine, but not one of the computers is sold.
Das Bord steckt in so einem Computer (1975)
Bild hier