include	clib.inc

PPROC	strrev, strp:DPTR
	push	si
	push	di
	MPUSH	ds
	cld
	MLDS	si,strp
	mov	dx,si
	mov	di,si
	push	ds
	pop	es
	xor	al,al
	mov	cx,-1
	repnz	scasb
	cmp	cx,-2
	je	strrev_02
	dec	di
	dec	di
	xchg	si,di
	jmp	strrev_01
    strrev_00:
	mov	al,[di]
	movsb
	mov	[si-1],al
	sub	si,2
    strrev_01:
	cmp	di,si
	jc	strrev_00
    strrev_02:
	xchg	ax,dx
	MMOV	dx,ds
	MPOP	ds
	pop	di
	pop	si
	ret
PEND	strrev

	END
