include	clib.inc

_TEXT	SEGMENT

hextoa proc dist pascal public uses si di string:dword
	les di,string
	mov si,di
    hextoa_00:
	mov ax,es:[si]
	inc si
	cmp al,' '
	je hextoa_00
	inc si
	mov dl,ah
	test al,al
	jz hextoa_03
	sub ax,'00'
	cmp al,9
	jbe hextoa_01
	sub al,7
    hextoa_01:
	shl al,4
	cmp ah,9
	jbe hextoa_02
	sub ah,7
    hextoa_02:
	or ah,al
	mov es:[di],ah
	inc di
	test dl,dl
	jnz hextoa_00
    hextoa_03:
	sub al,al
	mov es:[di],al
	mov dx,word ptr string+2
	mov ax,word ptr string
	ret
hextoa endp

_TEXT	ENDS

	END
