;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.5.0 #1020 (Oct 16 2005)
; This file generated Sun Oct 16 22:33:28 2005
;--------------------------------------------------------
	.module _atoi
	.optsdcc -mmcs51 --model-large
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _atoi
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
	.area RSEG    (DATA)
;--------------------------------------------------------
; special function bits 
;--------------------------------------------------------
	.area RSEG    (DATA)
;--------------------------------------------------------
; overlayable register banks 
;--------------------------------------------------------
	.area REG_BANK_0	(REL,OVR,DATA)
	.ds 8
;--------------------------------------------------------
; internal ram data
;--------------------------------------------------------
	.area DSEG    (DATA)
;--------------------------------------------------------
; overlayable items in internal ram 
;--------------------------------------------------------
	.area OSEG    (OVR,DATA)
;--------------------------------------------------------
; indirectly addressable internal ram data
;--------------------------------------------------------
	.area ISEG    (DATA)
;--------------------------------------------------------
; bit data
;--------------------------------------------------------
	.area BSEG    (BIT)
;--------------------------------------------------------
; paged external ram data
;--------------------------------------------------------
	.area PSEG    (PAG,XDATA)
;--------------------------------------------------------
; external ram data
;--------------------------------------------------------
	.area XSEG    (XDATA)
_atoi_s_1_1::
	.ds 3
_atoi_rv_1_1::
	.ds 2
_atoi_sign_1_1::
	.ds 1
;--------------------------------------------------------
; external initialized ram data
;--------------------------------------------------------
	.area XISEG   (XDATA)
	.area CSEG    (CODE)
	.area GSINIT0 (CODE)
	.area GSINIT1 (CODE)
	.area GSINIT2 (CODE)
	.area GSINIT3 (CODE)
	.area GSINIT4 (CODE)
	.area GSINIT5 (CODE)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area CSEG    (CODE)
	.area GSINIT  (CODE)
	.area GSFINAL (CODE)
	.area GSINIT  (CODE)
;--------------------------------------------------------
; Home
;--------------------------------------------------------
	.area HOME    (CODE)
	.area CSEG    (CODE)
;--------------------------------------------------------
; code
;--------------------------------------------------------
	.area CSEG    (CODE)
;------------------------------------------------------------
;Allocation info for local variables in function 'atoi'
;------------------------------------------------------------
;s                         Allocated with name '_atoi_s_1_1'
;rv                        Allocated with name '_atoi_rv_1_1'
;sign                      Allocated with name '_atoi_sign_1_1'
;------------------------------------------------------------
;_atoi.c:25: int atoi(char * s)
;	-----------------------------------------
;	 function atoi
;	-----------------------------------------
_atoi:
	ar2 = 0x02
	ar3 = 0x03
	ar4 = 0x04
	ar5 = 0x05
	ar6 = 0x06
	ar7 = 0x07
	ar0 = 0x00
	ar1 = 0x01
;     genReceive
	mov	r2,b
	mov	r3,dph
	mov	a,dpl
	mov	dptr,#_atoi_s_1_1
	movx	@dptr,a
	inc	dptr
	mov	a,r3
	movx	@dptr,a
	inc	dptr
	mov	a,r2
	movx	@dptr,a
;_atoi.c:27: register int rv=0; 
;     genAssign
	mov	dptr,#_atoi_rv_1_1
	clr	a
	movx	@dptr,a
	inc	dptr
	movx	@dptr,a
;_atoi.c:31: while (*s) {
;     genAssign
	mov	dptr,#_atoi_s_1_1
	movx	a,@dptr
	mov	r2,a
	inc	dptr
	movx	a,@dptr
	mov	r3,a
	inc	dptr
	movx	a,@dptr
	mov	r4,a
00107$:
;     genPointerGet
;     genGenPointerGet
	mov	dpl,r2
	mov	dph,r3
	mov	b,r4
	lcall	__gptrget
;     genIfx
;	Peephole 105	removed redundant mov
	mov	r5,a
;     genIfxJump
;	Peephole 110	removed ljmp by inverse jump logic
	jz	00109$
00133$:
;_atoi.c:32: if (*s <= '9' && *s >= '0')
;     genCmpGt
;     genCmp
	clr	c
;	Peephole 159	avoided xrl during execution
	mov	a,#(0x39 ^ 0x80)
	mov	b,r5
	xrl	b,#0x80
	subb	a,b
;     genIfxJump
;	Peephole 112.b	changed ljmp to sjmp
;	Peephole 160	removed sjmp by inverse jump logic
;     genCmpLt
;     genCmp
;	Peephole 256.a	removed redundant clr c
	jc	00102$
00134$:
	mov	a,r5
	xrl	a,#0x80
	subb	a,#0xb0
;     genIfxJump
;	Peephole 108	removed ljmp by inverse jump logic
	jnc	00109$
00135$:
;_atoi.c:33: break;
00102$:
;_atoi.c:34: if (*s == '-' || *s == '+') 
;     genPointerGet
;     genGenPointerGet
	mov	dpl,r2
	mov	dph,r3
	mov	b,r4
	lcall	__gptrget
	mov	r5,a
;     genCmpEq
	cjne	r5,#0x2D,00136$
;	Peephole 112.b	changed ljmp to sjmp
	sjmp	00109$
00136$:
;     genCmpEq
	cjne	r5,#0x2B,00137$
;	Peephole 112.b	changed ljmp to sjmp
	sjmp	00109$
00137$:
;_atoi.c:36: s++;
;     genPlus
;     genPlusIncr
	inc	r2
	cjne	r2,#0x00,00138$
	inc	r3
00138$:
;     genAssign
	mov	dptr,#_atoi_s_1_1
	mov	a,r2
	movx	@dptr,a
	inc	dptr
	mov	a,r3
	movx	@dptr,a
	inc	dptr
	mov	a,r4
	movx	@dptr,a
;	Peephole 112.b	changed ljmp to sjmp
	sjmp	00107$
00109$:
;_atoi.c:39: sign = (*s == '-');
;     genAssign
	mov	dptr,#_atoi_s_1_1
	mov	a,r2
	movx	@dptr,a
	inc	dptr
	mov	a,r3
	movx	@dptr,a
	inc	dptr
	mov	a,r4
	movx	@dptr,a
;     genPointerGet
;     genGenPointerGet
	mov	dpl,r2
	mov	dph,r3
	mov	b,r4
	lcall	__gptrget
	mov	r5,a
;     genCmpEq
;	Peephole 241.c	optimized compare
	clr	a
	cjne	r5,#0x2D,00139$
	inc	a
00139$:
00140$:
;     genAssign
;	Peephole 100	removed redundant mov
	mov	r6,a
	mov	dptr,#_atoi_sign_1_1
	movx	@dptr,a
;_atoi.c:40: if (*s == '-' || *s == '+') s++;
;     genIfx
	mov	a,r6
;     genIfxJump
;	Peephole 109	removed ljmp by inverse jump logic
	jnz	00110$
00141$:
;     genCmpEq
;	Peephole 112.b	changed ljmp to sjmp
;	Peephole 199	optimized misc jump sequence
	cjne	r5,#0x2B,00131$
;00142$:
;	Peephole 200	removed redundant sjmp
00143$:
00110$:
;     genPlus
	mov	dptr,#_atoi_s_1_1
;     genPlusIncr
	mov	a,#0x01
;	Peephole 236.a	used r2 instead of ar2
	add	a,r2
	movx	@dptr,a
;	Peephole 181	changed mov to clr
	clr	a
;	Peephole 236.b	used r3 instead of ar3
	addc	a,r3
	inc	dptr
	movx	@dptr,a
	inc	dptr
	mov	a,r4
	movx	@dptr,a
;_atoi.c:42: while (*s && *s >= '0' && *s <= '9') {
00131$:
;     genAssign
	mov	dptr,#_atoi_s_1_1
	movx	a,@dptr
	mov	r2,a
	inc	dptr
	movx	a,@dptr
	mov	r3,a
	inc	dptr
	movx	a,@dptr
	mov	r4,a
00115$:
;     genPointerGet
;     genGenPointerGet
	mov	dpl,r2
	mov	dph,r3
	mov	b,r4
	lcall	__gptrget
;     genIfx
;	Peephole 105	removed redundant mov
	mov	r5,a
;     genIfxJump
;	Peephole 110	removed ljmp by inverse jump logic
	jz	00117$
00144$:
;     genCmpLt
;     genCmp
	clr	c
	mov	a,r5
	xrl	a,#0x80
	subb	a,#0xb0
;     genIfxJump
;	Peephole 112.b	changed ljmp to sjmp
;	Peephole 160	removed sjmp by inverse jump logic
;     genCmpGt
;     genCmp
;	Peephole 256.a	removed redundant clr c
	jc	00117$
00145$:
;	Peephole 159	avoided xrl during execution
	mov	a,#(0x39 ^ 0x80)
	mov	b,r5
	xrl	b,#0x80
	subb	a,b
;     genIfxJump
;	Peephole 112.b	changed ljmp to sjmp
;	Peephole 160	removed sjmp by inverse jump logic
	jc	00117$
00146$:
;_atoi.c:43: rv = (rv * 10) + (*s - '0');
;     genAssign
	mov	dptr,#_atoi_rv_1_1
	movx	a,@dptr
	mov	r6,a
	inc	dptr
	movx	a,@dptr
	mov	r7,a
;     genAssign
	mov	dptr,#__mulint_PARM_2
	mov	a,#0x0A
	movx	@dptr,a
	clr	a
	inc	dptr
	movx	@dptr,a
;     genCall
	mov	dpl,r6
	mov	dph,r7
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	__mulint
	mov	r6,dpl
	mov	r7,dph
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genCast
	mov	a,r5
	rlc	a
	subb	a,acc
	mov	r0,a
;     genMinus
	mov	a,r5
	add	a,#0xd0
	mov	r5,a
	mov	a,r0
	addc	a,#0xff
	mov	r0,a
;     genPlus
	mov	dptr,#_atoi_rv_1_1
;	Peephole 236.g	used r5 instead of ar5
	mov	a,r5
;	Peephole 236.a	used r6 instead of ar6
	add	a,r6
	movx	@dptr,a
;	Peephole 236.g	used r0 instead of ar0
	mov	a,r0
;	Peephole 236.b	used r7 instead of ar7
	addc	a,r7
	inc	dptr
	movx	@dptr,a
;_atoi.c:44: s++;
;     genPlus
;     genPlusIncr
	inc	r2
	cjne	r2,#0x00,00147$
	inc	r3
00147$:
;     genAssign
	mov	dptr,#_atoi_s_1_1
	mov	a,r2
	movx	@dptr,a
	inc	dptr
	mov	a,r3
	movx	@dptr,a
	inc	dptr
	mov	a,r4
	movx	@dptr,a
	ljmp	00115$
00117$:
;_atoi.c:47: return (sign ? -rv : rv);
;     genAssign
	mov	dptr,#_atoi_s_1_1
	mov	a,r2
	movx	@dptr,a
	inc	dptr
	mov	a,r3
	movx	@dptr,a
	inc	dptr
	mov	a,r4
	movx	@dptr,a
;     genAssign
	mov	dptr,#_atoi_sign_1_1
	movx	a,@dptr
;     genIfx
;	Peephole 105	removed redundant mov
	mov	r2,a
;     genIfxJump
;	Peephole 110	removed ljmp by inverse jump logic
	jz	00120$
00148$:
;     genAssign
	mov	dptr,#_atoi_rv_1_1
	movx	a,@dptr
	mov	r2,a
	inc	dptr
	movx	a,@dptr
	mov	r3,a
;     genUminus
	clr	c
	clr	a
	subb	a,r2
	mov	r2,a
	clr	a
	subb	a,r3
	mov	r3,a
;	Peephole 112.b	changed ljmp to sjmp
	sjmp	00121$
00120$:
;     genAssign
	mov	dptr,#_atoi_rv_1_1
	movx	a,@dptr
	mov	r2,a
	inc	dptr
	movx	a,@dptr
	mov	r3,a
00121$:
;     genRet
	mov	dpl,r2
	mov	dph,r3
00118$:
	ret
	.area CSEG    (CODE)
	.area XINIT   (CODE)
