	INCLUDE CCHEADER.CCC
;double
;atof(cp)
;register char *cp;
	public atof_
atof_ proc	near
	mov ax,$2
	call $sav
;{
	mov di,8[bp]
;	double acc;
;	int msign, esign, dpflg;
;	int i, dexp;
;	int ten = 10, zero = 0;
;	if (*cp == '-') {
	cmp byte ptr [di],45
	jne $3
;		++cp;
	inc di
;		msign = 1;
	mov word ptr -10[bp],1
;	} else {
	jmp $4
$3:
;		msign = 0;
	mov word ptr -10[bp],0
;		if (*cp == '+')
;			++cp;
	cmp byte ptr [di],43
	jne $5
	inc di
;	}
$5:
$4:
;	dpflg = dexp = 0;
	mov ax,0
	mov word ptr -18[bp],ax
	mov word ptr -14[bp],ax
;	for (acc = zero ; ; ++cp) {
	call	$dlip
	dw	0,0,0,0
$6:
;		if (isdigit(*cp)) {
	mov al,0[di]
	cmp	al,'0'
	jb	$9
	cmp	al,'9'
	ja	$9
;			acc *= ten;
	call	$dlis
	dw	0,0,0,4024H
	call $dml
;			acc += *cp - '0';
	call	$dswap
	mov al,0[di]
	cbw
	add ax,-48
	call $itod
	call $dad
;			if (dpflg)
;				--dexp;
	cmp word ptr -14[bp],0
	je $10
	add word ptr -18[bp],-1
;		} else if (*cp == '.') {
$10:
	jmp $11
$9:
	cmp al,'.'
	jne $12
;			if (dpflg)
;				break;
	cmp word ptr -14[bp],0
	jne $8
;			dpflg = 1;
	mov word ptr -14[bp],1
;		} else
	jmp $13
$12:
;			break;
	jmp $8
$13:
$11:
;	}
	inc di
	jmp $6
$8:
;	if (*cp == 'e' || *cp == 'E') {
	cmp byte ptr [di],101
	je $15
	cmp byte ptr [di],69
	jne $14
$15:
;		++cp;
	inc di
;		if (*cp == '-') {
	cmp byte ptr [di],45
	jne $16
;			++cp;
	inc di
;			esign = 1;
	mov word ptr -12[bp],1
;		} else {
	jmp $17
$16:
;			esign = 0;
	mov word ptr -12[bp],0
;			if (*cp == '+')
;				++cp;
	cmp byte ptr [di],43
	jne $18
	inc di
;		}
$18:
$17:
;		for ( i = 0 ; isdigit(*cp) ; i = i*10 + *cp++ - '0' )
	sub	ax,ax
	mov cx,10
	jmp $20
$19:
	mul cx
	mov	dx,ax
	mov al,[di]
	inc di
	cbw
	add ax,dx
	add ax,-48
$20:
	mov bl,0[di]
	cmp	bl,'0'
	jb $21
	cmp	bl,'9'
	jbe $19
;			;
$21:
;		if (esign)
;			i = -i;
	cmp word ptr -12[bp],0
	je $22
	neg ax
$22:
;		dexp += i;
	add word ptr -18[bp],ax
;	}
;	if (dexp < 0) {
$14:
	call	$dlis
	dw	0,0,0,4024H
	mov si,word ptr -18[bp]
	test	si,si
	jns $23
;		while (dexp++)
$24:
;			acc /= ten;
	call $ddv
	inc	si
	jnz	$24
;	} else if (dexp > 0) {
	jmp $26
$23:
	jz $27
;		while (dexp--)
$28:
;			acc *= ten;
	call $dml
	dec	si
	jnz $28
$29:
;	}
;	if (msign)
$27:
$26:
;		acc = -acc;
	cmp word ptr -10[bp],0
	je $30
	call $dng
;	return acc;
$30:
	ret
;}
$2 = -22
atof_ endp
$lngused = 0
$fltused = 1
	tailcode
	end
