include	clib.inc
include	string.inc
include	stdlib.inc

PPROC	qwtobstr, odx:dword, oax:dword
	push	si
	push	di
	pushm	odx
	pushm	oax
	call	qwtostr
	push	dx
	push	ax
	call	strrev
	mov	si,ax
	mov	di,offset result
	xor	dx,dx
    qwtobstr_loop:
	lodsb
	stosb
	test	al,al
	jz	qwtobstr_end
	inc	dx
	cmp	dx,3
	jnz	qwtobstr_loop
	mov	al,' '
	stosb
	xor	dx,dx
	jmp	qwtobstr_loop
    qwtobstr_end:
	cmp	byte ptr [di-2],' '
	jnz	qwtobstr_rev
	mov	[di-2],dh
    qwtobstr_rev:
	push	ds
	push	offset result
	call	strrev
	pop	di
	pop	si
	ret
PEND	qwtobstr

_DATA	SEGMENT

result 	db 24 dup(?)

_DATA	ENDS

	END
