include	clib.inc
include	time.inc
include	stdlib.inc

_TEXT	SEGMENT

strtotw proc dist pascal public uses si di string:dword
	sub ax,ax
	les bx,string
	.repeat
	    mov al,es:[bx]
	    inc bx
	.until al > '9' || al < '0'
	.if al
	    mov ax,word ptr string+2
	    push ax
	    push bx
	    push ax
	    push word ptr string
	    mov word ptr string,bx
	    call atol
	    mov si,ax
	    call atol
	    mov di,ax
	    les bx,string
	    sub ax,ax
	    .repeat
		mov al,es:[bx]
		inc bx
	    .until al > '9' || al < '0'
	    .if al
		push word ptr string+2
		    push bx
		call atol
	    	shr ax,1
	    	shl di,5
	    	shl si,11
	    	or ax,si
	    	or ax,di
	    .endif
	.endif
	ret
strtotw endp

_TEXT	ENDS

	END
