	org	100h
	jmp	start
	db	'aus lifelines III/5'
start:	lxi	h,0
	dad	d
	shld	stack
	lxi	sp,stack
	lda	fcb+1
	cpi	' '
	jz	nonam
	lxi	d,fcb
	mvi	c,open
	call	bdos
	inr	a
	jz	opner
	call	lin1st
rdlp:	lxi	d,fcb
	mvi	c,read
	call	bdos
	ora	a
	jnz	rder
	lxi	d,80h
	lhld	addr
	dad	d
	shld	addr
line:	mov	a,h
	call	xo
	mov	a,l
	call	xob
	push	d
char:	ldax	d
	inx	d
	inx	h
	call	xo
	mov	a,e
	ani	3
	cz	space
	mov	a,e
	ani	0fh
	jnz	char
	pop	d
	call	ast
ascic:	ldax	d
	cpi	' '
	jc	per
	cpi	7fh
	jc	ok
per:	mvi	a,'.'
ok:	call	type
	inx	d
	mov	a,e
	ani	0fh
	jnz	ascic
	call	ast
	call	newlin
	mvi	a,13
	call	type
	mvi	a,10
	call	type
	mov	a,e
	ani	7fh
	jz	rdlp
	jmp	line
ast:	mvi	a,'*'
type:	push	b
	push	d
	push	h
	mov	e,a
	mvi	c,wrcon
	call	bdos
	mvi	c,const
	call	bdos
	dcr	a
	jz	exit
	pop	h
	pop	d
	pop	b
	ret
xo:	push	psw
	rar
	rar
	rar
	rar
	call	nibbl
	pop	psw
nibbl:	ani	0fh
	cpi	10
	jc	hexnu
	adi	7
hexnu:	adi	'0'
	jmp	type
xob:	call	xo
space:	mvi	a,' '
	jmp	type
rder:	dcr	a
	jnz	rderr
	jmp	exit
nonam:	lxi	d,msg1
	jmp	erxit
opner:	lxi	d,msg2
	jmp	erxit
rderr:	lxi	d,msg3
erxit:	mvi	c,print
	call	bdos
exit:	lhld	stack
	sphl
	ret
	ds	128
stack:	ds	2
msg1:	db	'NO FILE'
msg2:	db	'NO SUCH FILE'
msg3:	db	'read error'
msg4:	db	0dh,0ch,'$'
msg5:	db	'Addr  0 1 2 3  4 5 6 7  8 9 A B  C D E F  0123456789ABCDEF'
	db	0dh,0ah,0ah,'$'
lincnt:	db	64
addr:	dw	128
wrcon	equ	2
print	equ	9
const	equ	11
open	equ	15
read	equ	20
bdos	equ	5
fcb	equ	5ch
newlin:	push	h
	push	d
	push	b
	push	psw
	lda	lincnt
	dcr	a
	sta	lincnt
	jnz	return
line1:	mvi	c,print
	lxi	d,msg4	;print tof
	call	bdos
	mvi	c,print
	lxi	d,msg5	;print header
	call	bdos
	mvi	a,75
	sta	lincnt
return:	pop	psw
	pop	b
	pop	d
	pop	h
	ret
lin1st:	push	h
	push	d
	push	b
	push	psw
	jmp	line1
end
