include	clib.inc
include	string.inc

_TEXT	SEGMENT

strtrim proc dist pascal public uses di string:dword
	les di,string
	xor ax,ax
	cld
	mov cx,-1
	repne scasb
	not cx
	dec di
	mov ax,' '
      @@:
	dec di
	dec cx
	jz @F
	cmp es:[di],al
	ja @F
	mov es:[di],ah
	jmp @B
      @@:
	mov ax,di
	sub ax,word ptr string
	inc ax
	ret
strtrim endp

_TEXT	ENDS

	END
