/
/ DH-11 test.
/

DH	=	160020
DHVEC	=	330
DL	=	175610
CR	=	15
LF	=	12
PS	=	177776
TFTF	=	127307
OTTF	=	126307

	.entry	start

	.blkb	1000
stack:	.blkb	0

start:	reset
	mov	$stack,sp

	mov	$dhrt,r1
	jsr	pc,puts

	clr	DH+16
	mov	$1,DH
	mov	$TFTF,DH+4
	mov	$2,DH
	mov	$OTTF,DH+4
	mov	$5,DH
	mov	$TFTF,DH+4

	mov	$dhrint,DHVEC
	mov	$340,DHVEC+2
	bis	$100,DH
	clr	PS

0:	wait
	br	0b

dhrint:	mov	DH+2,r5
	bpl	1f

	mov	$' ,r0
	bit	$40000,r5
	beq	0f
	mov	$'o,r0
0:	jsr	pc,putc

	mov	$' ,r0
	bit	$20000,r5
	beq	0f
	mov	$'f,r0
0:	jsr	pc,putc

	mov	$' ,r0
	bit	$10000,r5
	beq	0f
	mov	$'p,r0
0:	jsr	pc,putc

	mov	$' ,r0
	jsr	pc,putc
	mov	$'#,r0
	jsr	pc,putc
	mov	r5,r0
	swab	r0
	bic	$!17,r0
	add	$'0,r0
	jsr	pc,putc

	mov	$' ,r0
	jsr	pc,putc
	mov	r5,r0
	asr	r0
	asr	r0
	asr	r0
	asr	r0
	asr	r0
	asr	r0
	bic	$!3,r0
	add	$'0,r0
	jsr	pc,putc
	mov	r5,r0
	asr	r0
	asr	r0
	asr	r0
	bic	$!7,r0
	add	$'0,r0
	jsr	pc,putc
	mov	r5,r0
	bic	$!7,r0
	add	$'0,r0
	jsr	pc,putc

	bic	$!177,r5
	cmp	r5,$' 
	blo	0f
	mov	$' ,r0
	jsr	pc,putc
	mov	$'',r0
	jsr	pc,putc
	mov	r5,r0
	jsr	pc,putc
	mov	$'',r0
	jsr	pc,putc

0:	mov	$CR,r0
	jsr	pc,putc
	mov	$LF,r0
	jsr	pc,putc
	br	dhrint

1:	rti

puts:	movb	(r1)+,r0
	beq	0f
	jsr	pc,putc
	br	puts

0:	rts	pc

putc:	tstb	DL+4
	bpl	putc
	movb	r0,DL+6
	rts	pc

dhrt:	.byte	CR, LF
	.ASCII	"Standalone DH-11 Receiver Test."
	.byte	CR, LF, 0
