/
/ PDP-11 C.
/ Standard Library.
/
/ Ascii to Integer.
/

	.globl	atoi

/
/ int atoi(p);
/ char *p;
/

atoi:
	jsr	r0,_save
	mov	12(r5),r0
	clr	r1
	clr	r2

0:
	movb	(r0)+,r3
	beq	1f
	cmpb	r3,$'-
	bne	0f
	com	r2
	br	0b

0:
	sub	$'0,r3
	cmp	r3,$9
	bhi	0f
	asl	r1
	mov	r1,-(sp)
	asl	r1
	asl	r1
	add	(sp)+,r1
	add	r3,r1
	movb	(r0)+,r3
	bne	0b

0:
	tst	r2
	beq	1f
	neg	r1

1:
	mov	r1,r0
	jmp	_ret
