upcase	macro	char
	local	nocvt

	ifb	<char>

	upcase	al

	else

	cmp	char,'a'
	jb	nocvt
	cmp	char,'z'
	ja	nocvt
	sub	char,32
nocvt:
	endif
	endm



	page	66,132

cseg	segment	byte public 'CODE'
	assume	cs:cseg,ds:cseg,es:cseg
	org	100h

start	proc	near
	jmp	start1

	db	13,'AT (c)1985 by Donavon Kuhn and Jon Niedfeldt',13,10,26

base	dw	0

start1:
	mov	bl,0			;default com port (COM1:)
	mov	si,80h
start2:
	inc	si
	mov	al,[si]			;space off leading spaces
	cmp	al,' '
	jz	start2

	cmp	al,'?'
	jz	errexit

	upcase				;using UPCASE without a parameter
	cmp	al,'C'			;(defaults to AL)
	jnz	nocom

	mov	cl,[si][1]
	upcase	cl			;using UPCASE using another register
	cmp	cl,'O'
	jnz	nocom
				

	mov	al,[si][2]
	upcase	al			;using UPCASE with AL as the parm
	cmp	al,'M'
	jnz	nocom

	cmp	byte ptr [si][4],':'
	jz	check_port

errexit:
	lea	dx,errmsg
errexit1:
	mov	ah,9
	int	21h

	mov	ax,4c01h		;return ERRORLEVEL of 1
	int	21h

check_port:
	mov	al,[si][3]		;get the com number
	sub	al,'1'			;convert to binary
	cmp	al,3			;greater than com4?
	ja	errexit

	add	si,5

	mov	bl,al
nocom:
	xor	bh,bh	
	shl	bl,1
	mov	ax,40h
	mov	ds,ax
	mov	ax,ds:[bx]
	push	cs
	pop	ds

	cmp	ax,0
	jnz	comok

	lea	dx,ncstr
	jmp	errexit1


comok:
	mov	base,ax

	mov	al,'A'
	call	auxout
	mov	al,'T'
	call	auxout

outlp:
	mov	al,[si]
	inc	si
	call	auxout
	cmp	al,13
	jnz	outlp

	mov	ax,4c00h
	int	21h

errmsg	db	'Usage:  AT [COM1:|COM2:|COM3:|COM4:] command string',13,10,'$'
ncstr	db	'COM port not found',13,10,'$'


auxout	proc	near
	push	ax
	mov	dx,base
	add	dx,5

txlp:
	in	al,dx
	and	al,20h
	jz	txlp

	pop	ax
	sub	dx,5
	out	dx,al	
	ret
auxout	endp
;
;---------------
;
start	endp

cseg	ends
    	end	start

