/
/ Ascii to long using octal input.
/

	.globl	atolo

/
/ long atolo(*s);
/ char *s;
/ Convert ascii octal string to a long
/ int.
/

atolo:	jsr	r0,__csav	/ Linkage

	mov	12(r5),r4	/ r4 = ptr to string
	clr	r3		/ r3 = sign flag
	clr	r1		/ r1 = low
	clr	r0		/ r0 = high

0:	movb	(r4)+,r2	/ Grab character.
	beq	1f		/ Done
	cmp	r2,$'\t		/ Ignore tabs
	beq	0b		/
	cmp	r2,$'\n		/ Newlines
	beq	0b		/
	cmp	r2,$'+		/ `+' signs
	beq	0b		/
	cmp	r2,$' 		/ and spaces
	beq	0b		/

	cmp	r2,$'-		/ If `-'
	bne	0f		/ then
	inc	r3		/ hit sign flag and
	br	0b		/ ignore

0:	sub	$'0,r2		/ Make int
	cmp	r2,$7		/ Legal ?
	bhi	0f		/ No
	asl	r1		/ r[01] = 8*r[01]
	rol	r0		/
	asl	r1		/
	rol	r0		/
	asl	r1		/
	rol	r0		/
	add	r2,r1		/ Add in new digit
	adc	r0		/
	movb	(r4)+,r2	/ Get next
	bne	0b		/ Loop if not the end

0:	asr	r3		/ `-' ?
	bcc	1f		/ Nope
	neg	r0		/ Negate
	neg	r1		/
	sbc	r0		/

1:	jmp	__cret		/ Done
