
.equ    locat, 0xF300           ;Location for this program

.equ	cout, 0x0030
.equ    cin, 0x0032
.equ	pstr, 0x0038
.equ    newline, 0x0048


.org    locat
.db     0xA5,0xE5,0xE0,0xA5     ;signiture bytes
.db     35,255,0,0              ;id (35=prog)
.db     0,0,0,0                 ;prompt code vector
.db     0,0,0,0                 ;reserved
.db     0,0,0,0                 ;reserved
.db     0,0,0,0                 ;reserved
.db     0,0,0,0                 ;user defined
.db     255,255,255,255         ;length and checksum (255=unused)
.db     "Serial Port Mux Test",0;max 31 characters, plus the zero
.org    locat+64                ;executable code begins here

main_loop:
	setb	p3.4		;enable comm to main port

	mov	dptr, #mesg1
	lcall	pstr		;send mesg1 to the main port
	jnb	ti, *		;wait for it all to leave

	jb	ri, done

	clr	p3.4		;redirect output to aux port

	mov	dptr, #mesg2
	lcall	pstr		;send mesg2 to the aux port
	jnb	ti, *		;wait for it all to leave

	jnb	ri, main_loop

done:
	lcall	cin
	push	acc
	mov	dptr, #mesg3
	lcall	pstr
	pop	acc
	lcall	cout
	lcall	newline
	jnb	ti, *		;wait for it all to leave
	ret

mesg1:	.db "Main Serial Port... both ports should be getting messages",13,10,0
mesg2:	.db "Aux Port... both ports should be getting messages",13,10,0
mesg3:	.db "Abort, receive char: ",0
