;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.6.0 #4309 (Oct 16 2006)
; This file generated Mon Oct 16 04:04:23 2006
;--------------------------------------------------------
	.module _atoi
	.optsdcc -mds400 --model-flat24
	
;--------------------------------------------------------
; CPU specific extensions
;--------------------------------------------------------
.flat24 on		; 24 bit flat addressing
dpl1	=	0x84
dph1	=	0x85
dps	=	0x86
dpx	=	0x93
dpx1	=	0x95
esp	=	0x9B
ap	=	0x9C
_ap	=	0x9C
mcnt0	=	0xD1
mcnt1	=	0xD2
ma	=	0xD3
mb	=	0xD4
mc	=	0xD5
F1	=	0xD1	; user flag
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _atoi
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; special function bits
;--------------------------------------------------------
;--------------------------------------------------------
; overlayable register banks
;--------------------------------------------------------
	.area REG_BANK_0	(REL,OVR,DATA)
	.ds 8
	.area REG_BANK_3	(REL,OVR,DATA)
	.ds 8
;--------------------------------------------------------
; internal ram data
;--------------------------------------------------------
	.area DSEG    (DATA)
_atoi_rv_1_1:
	.ds 2
;--------------------------------------------------------
; 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)
;--------------------------------------------------------
; external initialized ram data
;--------------------------------------------------------
	.area XISEG   (XDATA)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.area HOME    (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'
;------------------------------------------------------------
;rv                        Allocated with name '_atoi_rv_1_1'
;sign                      Allocated to registers r0 
;s                         Allocated to registers r2 r3 r4 r5 
;sloc0                     Allocated with name '_atoi_sloc0_1_0'
;------------------------------------------------------------
;	_atoi.c:25: int atoi(char * s)
;	genFunction
;	-----------------------------------------
;	 function atoi
;	-----------------------------------------
_atoi:
	ar2 = 0x02
	ar3 = 0x03
	ar4 = 0x04
	ar5 = 0x05
	ar6 = 0x06
	ar7 = 0x07
	ar0 = 0x00
	ar1 = 0x01
;	genReceive
	mov	r2,dpl
	mov	r3,dph
	mov	r4,dpx
	mov	r5,b
;	_atoi.c:27: register int rv=0; 
;	genAssign
;	genAssign: resultIsFar = FALSE
	clr	a
	mov	_atoi_rv_1_1,a
	mov	(_atoi_rv_1_1 + 1),a
;	_atoi.c:31: while (*s) {
;	genAssign
;	genAssign: resultIsFar = FALSE
	mov	ar0,r2
	mov	ar1,r3
	mov	ar6,r4
	mov	ar7,r5
;	genLabel
00107$:
;	genPointerGet
;	genGenPointerGet
	mov	dpl,r0
	mov	dph,r1
	mov	dpx,r6
	mov	b,r7
	lcall	__gptrget
;	genIfx
; Peephole 105   removed redundant mov
	mov  r2,a
;	genIfxJump
; Peephole 110   removed ljmp by inverse jump logic
	jz  00133$
00135$:
;	_atoi.c:32: if (*s <= '9' && *s >= '0')
;	genCmpGt
;	genCmp
	clr	c
; Peephole 159   avoided xrl during execution
	mov  a,#(0x39 ^ 0x80)
	mov	b,r2
	xrl	b,#0x80
	subb	a,b
;	genIfxJump
; Peephole 132   changed ljmp to sjmp
; Peephole 160   removed sjmp by inverse jump logic
	jc   00102$
00136$:
;	genCmpLt
;	genCmp
	clr	c
	mov	a,r2
	xrl	a,#0x80
	subb	a,#0xB0
;	genIfxJump
; Peephole 108   removed ljmp by inverse jump logic
	jnc  00133$
00137$:
;	_atoi.c:33: break;
;	genLabel
00102$:
;	_atoi.c:34: if (*s == '-' || *s == '+') 
;	genPointerGet
;	genGenPointerGet
	mov	dpl,r0
	mov	dph,r1
	mov	dpx,r6
	mov	b,r7
	lcall	__gptrget
;	genCmpEq
;	gencjneshort
; Peephole 105   removed redundant mov
	mov  r2,a
	cjne	a,#0x2D,00138$
; Peephole 132   changed ljmp to sjmp
	sjmp 00133$
00138$:
;	genCmpEq
;	gencjneshort
	mov	a,r2
	cjne	a,#0x2B,00139$
; Peephole 132   changed ljmp to sjmp
	sjmp 00133$
00139$:
;	_atoi.c:36: s++;
;	genPlus
	inc	r0
	cjne	r0,#0,00140$
	inc	r1
	cjne	r1,#0,00140$
	inc	r6
00140$:
;	did genPlusIncr
;	genGoto
;	genLabel
; Peephole 132   changed ljmp to sjmp
	sjmp 00107$
00133$:
;	genAssign
;	genAssign: resultIsFar = TRUE
	mov	ar2,r0
	mov	ar3,r1
	mov	ar4,r6
	mov	ar5,r7
;	_atoi.c:39: sign = (*s == '-');
;	genPointerGet
;	genGenPointerGet
	mov	dpl,r0
	mov	dph,r1
	mov	dpx,r6
	mov	b,r7
	lcall	__gptrget
;	genCmpEq
;	gencjne
;	gencjneshort
; Peephole 105   removed redundant mov
	mov  r6,a
	cjne	a,#0x2D,00141$
	mov	a,#1
	sjmp	00142$
00141$:
	clr	a
00142$:
;	genAssign
;	genAssign: resultIsFar = FALSE
;	_atoi.c:40: if (*s == '-' || *s == '+') s++;
;	genIfx
; Peephole 166   removed redundant mov
	mov  r7,a
	mov  ar0,r7 
;	genIfxJump
; Peephole 109   removed ljmp by inverse jump logic
	jnz  00110$
00143$:
;	genCmpEq
;	gencjneshort
	mov	a,r6
; Peephole 132   changed ljmp to sjmp
; Peephole 199   optimized misc jump sequence
	cjne a,#0x2B,00131$
;00144$:
; Peephole 200   removed redundant sjmp
00145$:
;	genLabel
00110$:
;	genPlus
	inc	r2
	cjne	r2,#0,00146$
	inc	r3
	cjne	r3,#0,00146$
	inc	r4
00146$:
;	did genPlusIncr
;	_atoi.c:42: while (*s && *s >= '0' && *s <= '9') {
;	genLabel
00131$:
;	genAssign
;	genAssign: resultIsFar = FALSE
;	genLabel
00115$:
;	genPointerGet
;	genGenPointerGet
	mov	dpl,r2
	mov	dph,r3
	mov	dpx,r4
	mov	b,r5
	lcall	__gptrget
;	genIfx
; Peephole 105   removed redundant mov
	mov  r6,a
;	genIfxJump
; Peephole 110   removed ljmp by inverse jump logic
	jz  00117$
00147$:
;	genCmpLt
;	genCmp
	clr	c
	mov	a,r6
	xrl	a,#0x80
	subb	a,#0xB0
;	genIfxJump
; Peephole 132   changed ljmp to sjmp
; Peephole 160   removed sjmp by inverse jump logic
	jc   00117$
00148$:
;	genCmpGt
;	genCmp
	clr	c
; Peephole 159   avoided xrl during execution
	mov  a,#(0x39 ^ 0x80)
	mov	b,r6
	xrl	b,#0x80
	subb	a,b
;	genIfxJump
; Peephole 132   changed ljmp to sjmp
; Peephole 160   removed sjmp by inverse jump logic
	jc   00117$
00149$:
;	_atoi.c:43: rv = (rv * 10) + (*s - '0');
;	genIpush
	push	ar0
;	genAssign
;	genAssign: resultIsFar = TRUE
	mov	dptr,#__mulint_PARM_2
	mov	a,#0x0A
	movx	@dptr,a
	clr	a
	inc	dptr
	movx	@dptr,a
;	genCall
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	push	ar6
	push	ar0
;	genSend argreg = 1, size = 2 
	mov	dpl,_atoi_rv_1_1
	mov	dph,(_atoi_rv_1_1 + 1)
	lcall	__mulint
	mov	r7,dpl
	mov	r1,dph
	pop	ar0
	pop	ar6
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;	genCast
	mov	a,r6
	rlc	a
	subb	a,acc
	mov	r0,a
;	genMinus
	mov	a,r6
	add	a,#0xD0
	mov	r6,a
	mov	a,r0
	addc	a,#0xFF
	mov	r0,a
;	genPlus
	mov	a,r6
	add	a,r7
	mov	_atoi_rv_1_1,a
	mov	a,r0
	addc	a,r1
	mov	(_atoi_rv_1_1 + 1),a
;	_atoi.c:44: s++;
;	genPlus
	inc	r2
	cjne	r2,#0,00150$
	inc	r3
	cjne	r3,#0,00150$
	inc	r4
00150$:
;	did genPlusIncr
;	genIpop
	pop	ar0
;	genGoto
;	genLabel
; Peephole 132   changed ljmp to sjmp
	sjmp 00115$
00117$:
;	_atoi.c:47: return (sign ? -rv : rv);
;	genIfx
	mov	a,r0
;	genIfxJump
; Peephole 110   removed ljmp by inverse jump logic
	jz  00120$
00151$:
;	genUminus
	clr	c
	clr	a
	subb	a,_atoi_rv_1_1
	mov	dpl,a
	clr	a
	subb	a,(_atoi_rv_1_1 + 1)
	mov	dph,a
;	genGoto
;	genLabel
; Peephole 132   changed ljmp to sjmp
	sjmp 00121$
00120$:
;	genAssign
;	genAssign: resultIsFar = FALSE
	mov	dpl,_atoi_rv_1_1
	mov	dph,(_atoi_rv_1_1 + 1)
;	genLabel
00121$:
;	genRet
;	genLabel
00118$:
;	genEndFunction
	ret
	.area CSEG    (CODE)
	.area CONST   (CODE)
	.area XINIT   (CODE)
