

		title	upper - filter
;
;		author: Gary R. Cantrell
;
;		This filter reads data from the standard input
;		device, converts to upper case and writes to the
;		standard output device.
;
;		usage:	upper < [d:][path]filename[.ext]
;				-or-
;			[filter |] upper [| filter]
;
;		requires: DOS 2.0 & runs as COM module
;
cseg		segment para public 'code'
		assume	cs:cseg,ds:cseg,es:cseg,ss:cseg
		org	100h			;offset for com module
upper		proc	far
		mov	ah,30h			;get DOS version
		int	21h
		cmp	ax,0002h
		jnb	version_ok
		mov	dx,offset ver_err	;bomb out on lesser version
		mov	ah,9
		int	21h
		int	20h
version_ok:	xor	bx,bx			;zero is stdin
		mov	ah,45h			;duplicate stdin handle
		int	21h
		mov	bp,ax			;save the handle returned
		mov	ah,3eh			;close the old handle
		int	21h
		mov	bx,2			;two is stderr
		mov	ah,45h			;duplicate stderr handle
		int	21h
read_block:	cld				;set scan direction
		mov	dx,offset buffer	;set input buffer
		mov	ax,length buffer	; and length
		mov	cx,ax
		mov	bx,bp			;point to stdin
		mov	ah,3fh			;read stdin for CX length
		int	21h			;read input
		or	ax,ax			;test return code
		jnz	$+4
		int	20h			;return to DOS
		mov	cx,ax			;number of bytes read
		mov	si,dx			;start of buffer
getc:		lodsb
		cmp	al,97			;skip conversion
		jb	putc			;  if not
		cmp	al,122			;    lower case
		ja	putc
		and	al,11011111b		;convert to upper case
putc:		mov	dl,al			;put character to stdout
		mov	ah,2
		int	21h
		dec	cx			;decrement block count
		jcxz	read_block		;at end, read next block
		jmp	getc
;
ver_err 	db	'upper: incorrect dos version'
buffer		db	512 dup(0)		;buffer area
		db	0
upper		endp
cseg		ends
		end	upper

13 minutes remaining.
Enter command (with leading period):

>	;buffer area
		