;       SCCSID = @(#)conout.inc	6.1 90/11/17
;	SCCSID = @(#)conout.inc	13.1 88/12/01

COM1_PORT	equ	03f8H
COM2_PORT	equ	02f8H

COM_DAT		equ	00H
COM_IEN		equ	01H		; interrupt enable
COM_IER		equ	02H		; interrupt ID
COM_LCR		equ	03H		; line control registers
COM_MCR		equ	04H		; modem control register
COM_LSR		equ	05H		; line status register
COM_MSR		equ	06H		; modem status regiser
COM_DLL		equ	00H		; divisor latch least sig
COM_DLM		equ	01H		; divisor latch most sig

;***	conout - write a single character to com2
;
;	Note: character must not be in AL, DL, or DH.
;
;	USES	NONE

conout	macro	char
local l1
	pushf
	push	ax
	push	dx
	mov	dx,COM2_PORT + COM_LSR
l1:	in	al,dx
	test	al,20h
	jz	short l1
	mov	al,char
	add	dl,COM_DAT - COM_LSR
	out	dx,al
	pop	dx
	pop	ax
	popf
endm


;***	strout - write a string to com2
;
;	USES	NONE

strout	macro	text
local	mesbeg, mesend, l0

	jmp	short mesend
mesbeg	db	text, 0Dh, 0Ah
mesend:	push	ax
	push	cx
	push	si
	push	ds
	pushf
	mov	si,offset cs:mesbeg
	mov	cx,mesend - mesbeg
	push	cs
	pop	ds
	cld
l0:	lodsb
	mov	ah,al
	conout	ah
	loop	l0
	popf
	pop	ds
	pop	si
	pop	cx
	pop	ax

endm


;***	hexout - write a 16-bit hex value to com2
;
;	USES	NONE

hexout	macro	value
local	tab, tabend, l0

	jmp	short tabend
tab	db	'0123456789ABCDEF'
tabend: pushf
	push	ax
	push	bx
	push	cx
	push	dx
	mov	bx,offset cs:tab
	mov	cx,4
	mov	dx,value
l0:	rol	dx,4
	push	dx
	mov	al,dl
	and	al,0Fh
	xlat	byte ptr cs:[bx]
	mov	ah,al
	conout	ah
	pop	dx
	loop	l0
	pop	dx
	pop	cx
	pop	bx
	pop	ax
	popf

endm
