	page	95,132
;
;                                                                          
;            }`J@RpNg@vg@[eBeB            
;                                                                          
;   Multicolumn Compact PRint utility   lboqDdwd  uP.SO    
;   ~           ~       ~~                                                 
;              Copyright (C) by n MY 1989-1990. All rights reserved.  
;
	public	asctoint
	public	inttoascs
	public	inttoasc0
	public	inttoascb
	public	getarg
	public	filelist
	public	abort
	public	errorno
	public	dosstdout
;
data	segment para	public	'DATA'
;
errorno     dw	    ?
;
data	ends
;
code	segment para	public	'CODE'
	assume	cs:code,ds:data
;
asctoint    proc
;
	push	bx
	push	cx
	push	dx
	xor	ax,ax
	mov	cx,ax
	mov	bx,10
looplabel:
	mov	cl,es:[di]
	cmp	cl,'0'
	jb	tointend
	cmp	cl,'9'
	ja	tointend
	and	cl,0fh
	mul	bx
	add	ax,cx
	inc	di
	jmp	short	looplabel
tointend:
	test	ax,ax
	pop	dx
	pop	cx
	pop	bx
	ret
;
asctoint    endp
;
inttoascs   proc
;
	push	cx
	push	dx
	cld
	mov	cx,100
	xor	dx,dx
	div	cx
	div	cl
	test	al,al
	jnz	allput5
	test	ah,ah
	jz	supressd
	mov	al,ah
	aam
	test	ah,ah
	jnz	allput4
	add	al,'0'
	stosb
	jmp	short	allput3
supressd:
	mov	al,dl
	aam
	test	ah,ah
	jnz	allput2
	add	al,'0'
lastone:
	stosb
	jmp	short	toascsend
;
allput5:
	add	al,'0'
	stosb
	mov	al,ah
	aam
allput4:
	add	ax,'00'
	xchg	ah,al
	stosw
allput3:
	mov	al,dl
	aam
allput2:
	add	ax,'00'
	xchg	ah,al
	stosw
toascsend:
	pop	dx
	pop	cx
	ret
;
inttoascs   endp
;
inttoasc0   proc
;
	push	cx
	push	dx
	cld
	mov	cx,100
	xor	dx,dx
	div	cx
	div	cl
	add	al,'0'
	stosb
	mov	al,ah
	aam
	add	ax,'00'
	xchg	ah,al
	stosw
	mov	al,dl
	aam
	add	ax,'00'
	xchg	ah,al
	stosw
	pop	dx
	pop	cx
	ret
;
inttoasc0   endp
;
inttoascb   proc
;
	push	cx
	push	dx
	cld
	mov	cx,100
	xor	dx,dx
	div	cx
	div	cl
	add	al,'0'
	stosb
	mov	al,ah
	aam
	add	ax,'00'
	xchg	ah,al
	stosw
	mov	al,dl
	aam
	add	ax,'00'
	xchg	ah,al
	stosw
;
	push	di
	lea	di,[di-5]
	mov	cx,4
chgspcloop:
	cmp	byte ptr es:[di],'0'
	jne	chgend
	mov	byte ptr es:[di],' '
	inc	di
	loop	chgspcloop
chgend:
	pop	di
	pop	dx
	pop	cx
	ret
;
inttoascb   endp
;
strsvseg    equ     word ptr [bp+8]
returnadr   equ     word ptr [bp+6]
argvseg     equ     word ptr [bp+4]
argvoff     equ     word ptr [bp+2]
argcwrk     equ     word ptr [bp]
;
getarg	    proc
;
	sub	sp,140
	mov	bp,sp
	mov	strsvseg,ss
	mov	ax,[bp+140]
	mov	returnadr,ax
	mov	argvseg,es
	xor	ax,ax
	mov	argcwrk,ax
	mov	cx,ax
	mov	cl,ds:[80h]
	mov	si,cx
	inc	cx
	mov	bx,81h
	mov	byte ptr [si+bx],' '
spaceloop:
	cmp	byte ptr [bx],' '
	je	nextchar
	cmp	byte ptr [bx],09h
	jne	spaceout
nextchar:
	inc	bx
	loop	spaceloop
	jmp	argend
spaceout:
	mov	es:[di],bx
	lea	di,[di+4]
	inc	word ptr argcwrk
nospcloop:
	inc	word ptr es:[di-2]
	dec	cx
	jcxz	stringend
	inc	bx
	cmp	byte ptr [bx],' '
	je	stringend
	cmp	byte ptr [bx],09h
	je	stringend
	jmp	short nospcloop
stringend:
	mov	byte ptr [bx],0
	inc	bx
	loop	spaceloop
argend:
	mov	argvoff,di
	mov	ax,argcwrk
	std
	lea	di,[bp+141]
	test	ax,ax
	jz	noargs
argsetloop:
	sub	argvoff,4
	mov	si,argvoff
	mov	cx,es:[si+2]
	mov	es:[si+2],ss
	mov	si,es:[si]
	add	si,cx
	inc	cx
	mov	es,strsvseg
    rep movsb
	les	si,[bp+2]	    ;argvoff
	mov	es:[si],di
	inc	word ptr es:[si]
	dec	argcwrk
	jnz	argsetloop
noargs:
	dec	di
	mov	si,returnadr
	mov	ss:[di],si
	mov	sp,di
	test	ax,ax
	ret
;
getarg	    endp
;
copysiz equ	word ptr [bp]
fnamsiz equ	word ptr [bp+2]
saveds	equ	[bp+4]
namstr	equ	0
dtaadr	equ	4
bufadr	equ	8
bufoff	equ	8
bufseg	equ	10
bufsiz	equ	12
;
filelist    proc
;
	push	bp
	sub	sp,6
	mov	bp,sp
	mov	saveds,ds
	les	di,[bx].namstr
	call	pathsep
	mov	copysiz,cx
	mov	ah,4eh
	xor	cx,cx
	lds	dx,[bx].namstr
	int	21h
	jc	notfound
findloop:
	mov	ds,saveds
	les	di,[bx].dtaadr
	mov	cx,13
	xor	al,al
	cld
  repne scasb
	sub	cx,13
	neg	cx
	mov	fnamsiz,cx
	add	cx,copysiz
	sub	[bx].bufsiz,cx
	jae	existbuff
	add	[bx].bufsiz,cx
	jmp	short	srchout
existbuff:
	les	di,[bx].bufadr
	lds	si,[bx].namstr
	mov	cx,copysiz
    rep movsb
	mov	ds,saveds
	lds	si,[bx].dtaadr
	mov	cx,fnamsiz
    rep movsb
	mov	ds,saveds
	mov	[bx].bufoff,di
;
	mov	ah,4fh
	lds	dx,[bx].namstr
	xor	cx,cx
	int	21h
	jnc	findloop
notfound:
	mov	ds,saveds
srchout:
	add	sp,6
	pop	bp
	ret
;
filelist    endp
;
pathsep     proc
;
	mov	cx,0ffffh
	cld
	xor	al,al
	push	di
  repne scasb
	pop	di
	not	cx
	dec	cx
	jz	nonames
;
	push	cx
	xor	dx,dx
analysloop:
	mov	al,es:[di]
	inc	di
	cmp	al,':'
	je	findpathchar
	cmp	al,'\'
	je	findpathchar
	cmp	al,81h
	jb	nextanalys
	cmp	al,0a0h
	jb	knjchar
	cmp	al,0e0h
	jb	nextanalys
	cmp	al,0fdh
	jae	nextanalys
knjchar:
	inc	di
	dec	cx
	jz	analysend
	jmp	short nextanalys
findpathchar:
	mov	dx,cx
nextanalys:
	loop	analysloop
analysend:
	pop	cx
	test	dx,dx
	jz	nochar
	dec	dx
	sub	cx,dx
nonames:
	ret
;
nochar:
	xor	cx,cx
	ret
;
pathsep     endp
;
dosstdout   proc
;
	mov	ah,40h
	mov	bx,1
	int	21h
	jc	outerr
	ret
;
dosstdout   endp
;
abort	    proc
;
	mov	ax,seg	data
	mov	ds,ax
	mov	ah,40h
	mov	bx,1
	int	21h
;
	mov	ax,errorno
outerr:
	mov	ah,4ch
	int	21h
;
abort	    endp
;
code	ends
	end
