;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.4.0 Tue Oct 12 01:18:44 2004

;--------------------------------------------------------
	.module atan2f
	.optsdcc -mmcs51 --model-small
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _atan2f_PARM_2
	.globl _atan2f
;--------------------------------------------------------
; special function registers
;--------------------------------------------------------
;--------------------------------------------------------
; special function bits 
;--------------------------------------------------------
;--------------------------------------------------------
; overlayable register banks 
;--------------------------------------------------------
	.area REG_BANK_0	(REL,OVR,DATA)
	.ds 8
;--------------------------------------------------------
; internal ram data
;--------------------------------------------------------
	.area DSEG    (DATA)
_atan2f_PARM_2::
	.ds 4
_atan2f_r_1_1::
	.ds 4
;--------------------------------------------------------
; overlayable items in internal ram 
;--------------------------------------------------------
	.area OSEG    (OVR,DATA)
;--------------------------------------------------------
; indirectly addressable internal ram data
;--------------------------------------------------------
	.area ISEG    (DATA)
;--------------------------------------------------------
; bit data
;--------------------------------------------------------
	.area BSEG    (BIT)
;--------------------------------------------------------
; external ram data
;--------------------------------------------------------
	.area XSEG    (XDATA)
;--------------------------------------------------------
; external initialized ram data
;--------------------------------------------------------
	.area XISEG   (XDATA)
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
	.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 'atan2f'
;------------------------------------------------------------
;y                         Allocated with name '_atan2f_PARM_2'
;x                         Allocated to registers r2 r3 r4 r5 
;r                         Allocated with name '_atan2f_r_1_1'
;------------------------------------------------------------
;atan2f.c:24: float atan2f(const float x, const float y)
;	-----------------------------------------
;	 function atan2f
;	-----------------------------------------
_atan2f:
	ar2 = 0x02
	ar3 = 0x03
	ar4 = 0x04
	ar5 = 0x05
	ar6 = 0x06
	ar7 = 0x07
	ar0 = 0x00
	ar1 = 0x01
;     genReceive
;atan2f.c:28: if ((x==0.0) && (y==0.0))
;     genAssign
;     genCall
	mov     r2,dpl
	mov     r3,dph
	mov     r4,b
	mov     r5,a
	mov     ___fseq_PARM_2,#0x00
	mov     (___fseq_PARM_2 + 1),#0x00
	mov     (___fseq_PARM_2 + 2),#0x00
	mov     (___fseq_PARM_2 + 3),#0x00
;       Peephole 238.a  removed 4 redundant moves
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	___fseq
	mov	a,dpl
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genIfx
;     genIfxJump
;       Peephole 110    removed ljmp by inverse jump logic
	jz      00102$
00121$:
;     genAssign
	mov	___fseq_PARM_2,#0x00
	mov	(___fseq_PARM_2 + 1),#0x00
	mov	(___fseq_PARM_2 + 2),#0x00
	mov	(___fseq_PARM_2 + 3),#0x00
;     genCall
	mov	dpl,_atan2f_PARM_2
	mov	dph,(_atan2f_PARM_2 + 1)
	mov	b,(_atan2f_PARM_2 + 2)
	mov	a,(_atan2f_PARM_2 + 3)
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	___fseq
	mov	a,dpl
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genIfx
;     genIfxJump
;       Peephole 110    removed ljmp by inverse jump logic
	jz      00102$
00122$:
;atan2f.c:30: errno=EDOM;
;     genAssign
	clr	a
	mov	(_errno + 1),a
	mov	_errno,#0x21
;atan2f.c:31: return 0.0;
;     genRet
	mov	dpl,#0x00
;       Peephole 3.a    changed mov to clr
;       Peephole 3.b    changed mov to clr
	clr     a
	mov     dph,a
	mov     b,a
;       Peephole 251    replaced ljmp to ret with ret
	ret
00102$:
;atan2f.c:34: if(fabsf(y)>=fabsf(x))
;     genCall
	mov	dpl,_atan2f_PARM_2
	mov	dph,(_atan2f_PARM_2 + 1)
	mov	b,(_atan2f_PARM_2 + 2)
	mov	a,(_atan2f_PARM_2 + 3)
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	_fabsf
	mov	r6,dpl
	mov	r7,dph
	mov	r0,b
	mov	r1,a
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genCall
	mov	dpl,r2
	mov	dph,r3
	mov	b,r4
	mov	a,r5
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	push	ar6
	push	ar7
	push	ar0
	push	ar1
	lcall	_fabsf
	mov	___fslt_PARM_2,dpl
	mov	(___fslt_PARM_2 + 1),dph
	mov	(___fslt_PARM_2 + 2),b
	mov	(___fslt_PARM_2 + 3),a
	pop	ar1
	pop	ar0
	pop	ar7
	pop	ar6
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genCall
	mov	dpl,r6
	mov	dph,r7
	mov	b,r0
	mov	a,r1
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	___fslt
	mov	a,dpl
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genIfx
;     genIfxJump
	jz	00123$
	ljmp	00107$
00123$:
;atan2f.c:36: r=atanf(x/y);
;     genAssign
	mov	___fsdiv_PARM_2,_atan2f_PARM_2
	mov	(___fsdiv_PARM_2 + 1),(_atan2f_PARM_2 + 1)
	mov	(___fsdiv_PARM_2 + 2),(_atan2f_PARM_2 + 2)
	mov	(___fsdiv_PARM_2 + 3),(_atan2f_PARM_2 + 3)
;     genCall
	mov	dpl,r2
	mov	dph,r3
	mov	b,r4
	mov	a,r5
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	___fsdiv
	mov	r6,dpl
	mov	r7,dph
	mov	r0,b
	mov	r1,a
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genCall
	mov	dpl,r6
	mov	dph,r7
	mov	b,r0
	mov	a,r1
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	_atanf
	mov	_atan2f_r_1_1,dpl
	mov	(_atan2f_r_1_1 + 1),dph
	mov	(_atan2f_r_1_1 + 2),b
	mov	(_atan2f_r_1_1 + 3),a
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;atan2f.c:37: if(y<0.0) r+=(x>=0?PI:-PI);
;     genAssign
	mov	___fslt_PARM_2,#0x00
	mov	(___fslt_PARM_2 + 1),#0x00
	mov	(___fslt_PARM_2 + 2),#0x00
	mov	(___fslt_PARM_2 + 3),#0x00
;     genCall
	mov	dpl,_atan2f_PARM_2
	mov	dph,(_atan2f_PARM_2 + 1)
	mov	b,(_atan2f_PARM_2 + 2)
	mov	a,(_atan2f_PARM_2 + 3)
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	___fslt
	mov	a,dpl
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genIfx
;     genIfxJump
	jnz	00124$
	ljmp	00108$
00124$:
;     genAssign
	mov	___fslt_PARM_2,#0x00
	mov	(___fslt_PARM_2 + 1),#0x00
	mov	(___fslt_PARM_2 + 2),#0x00
	mov	(___fslt_PARM_2 + 3),#0x00
;     genCall
	mov	dpl,r2
	mov	dph,r3
	mov	b,r4
	mov	a,r5
	lcall	___fslt
;     genNot
;       Peephole 244.a  moving first to a instead of r6
	mov	a,dpl
	mov	r6,a
	cjne	a,#0x01,00125$
00125$:
	clr	a
	rlc	a
;     genIfx
;       Peephole 105    removed redundant mov
	mov     r6,a
;     genIfxJump
;       Peephole 110    removed ljmp by inverse jump logic
	jz      00111$
00126$:
;     genAssign
	mov	r6,#0xDB
	mov	r7,#0x0F
	mov	r0,#0x49
	mov	r1,#0x40
;       Peephole 112.b  changed ljmp to sjmp
	sjmp    00112$
00111$:
;     genAssign
	mov	r6,#0xDB
	mov	r7,#0x0F
	mov	r0,#0x49
	mov	r1,#0xC0
00112$:
;     genAssign
	mov	___fsadd_PARM_2,r6
	mov	(___fsadd_PARM_2 + 1),r7
	mov	(___fsadd_PARM_2 + 2),r0
	mov	(___fsadd_PARM_2 + 3),r1
;     genCall
	mov	dpl,_atan2f_r_1_1
	mov	dph,(_atan2f_r_1_1 + 1)
	mov	b,(_atan2f_r_1_1 + 2)
	mov	a,(_atan2f_r_1_1 + 3)
	lcall	___fsadd
	mov	_atan2f_r_1_1,dpl
	mov	(_atan2f_r_1_1 + 1),dph
	mov	(_atan2f_r_1_1 + 2),b
	mov	(_atan2f_r_1_1 + 3),a
	ljmp	00108$
00107$:
;atan2f.c:41: r=-atanf(y/x);
;     genAssign
	mov	___fsdiv_PARM_2,r2
	mov	(___fsdiv_PARM_2 + 1),r3
	mov	(___fsdiv_PARM_2 + 2),r4
	mov	(___fsdiv_PARM_2 + 3),r5
;     genCall
	mov	dpl,_atan2f_PARM_2
	mov	dph,(_atan2f_PARM_2 + 1)
	mov	b,(_atan2f_PARM_2 + 2)
	mov	a,(_atan2f_PARM_2 + 3)
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	___fsdiv
	mov	r6,dpl
	mov	r7,dph
	mov	r0,b
	mov	r1,a
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genCall
	mov	dpl,r6
	mov	dph,r7
	mov	b,r0
	mov	a,r1
	push	ar2
	push	ar3
	push	ar4
	push	ar5
	lcall	_atanf
	mov	r6,dpl
	mov	r7,dph
	mov	r0,b
	mov	r1,a
	pop	ar5
	pop	ar4
	pop	ar3
	pop	ar2
;     genUminus
;     genUminusFloat
	mov	_atan2f_r_1_1,r6
	mov	(_atan2f_r_1_1 + 1),r7
	mov	(_atan2f_r_1_1 + 2),r0
	mov	a,r1
	cpl	acc.7
	mov	(_atan2f_r_1_1 + 3),a
;atan2f.c:42: r+=(x<0.0?-HALF_PI:HALF_PI);
;     genAssign
	mov	___fslt_PARM_2,#0x00
	mov	(___fslt_PARM_2 + 1),#0x00
	mov	(___fslt_PARM_2 + 2),#0x00
	mov	(___fslt_PARM_2 + 3),#0x00
;     genCall
	mov	dpl,r2
	mov	dph,r3
	mov	b,r4
	mov	a,r5
	lcall	___fslt
	mov	a,dpl
;     genIfx
;     genIfxJump
;       Peephole 110    removed ljmp by inverse jump logic
	jz      00113$
00127$:
;     genAssign
	mov	r2,#0xDB
	mov	r3,#0x0F
	mov	r4,#0xC9
	mov	r5,#0xBF
;       Peephole 112.b  changed ljmp to sjmp
	sjmp    00114$
00113$:
;     genAssign
	mov	r2,#0xDB
	mov	r3,#0x0F
	mov	r4,#0xC9
	mov	r5,#0x3F
00114$:
;     genAssign
	mov	___fsadd_PARM_2,r2
	mov	(___fsadd_PARM_2 + 1),r3
	mov	(___fsadd_PARM_2 + 2),r4
	mov	(___fsadd_PARM_2 + 3),r5
;     genCall
	mov	dpl,_atan2f_r_1_1
	mov	dph,(_atan2f_r_1_1 + 1)
	mov	b,(_atan2f_r_1_1 + 2)
	mov	a,(_atan2f_r_1_1 + 3)
	lcall	___fsadd
	mov	_atan2f_r_1_1,dpl
	mov	(_atan2f_r_1_1 + 1),dph
	mov	(_atan2f_r_1_1 + 2),b
	mov	(_atan2f_r_1_1 + 3),a
00108$:
;atan2f.c:44: return r;
;     genRet
	mov	dpl,_atan2f_r_1_1
	mov	dph,(_atan2f_r_1_1 + 1)
	mov	b,(_atan2f_r_1_1 + 2)
	mov	a,(_atan2f_r_1_1 + 3)
00109$:
	ret
	.area CSEG    (CODE)
	.area XINIT   (CODE)
