*** atan2.s
* 	Double Precision Arc Tangent
*	for Alcyon C
*
*	double atan2(d1,d2)
*	double d1,d2; (d2 > 0) (-1 <= (d1/d2) <= 1)
*
*	Copyright Atari Corp. 1987,1988
*
*	MDJohnson       2/15/88
***

	.include fpmacro

; atan2(x,y)
	fpinit	atan2
	fpidle				; wait for idle state
	move.w	#$5400,FPCMD		; x -> fp0
	ckcir	#$9608			; ready for double
	move.l	4(sp),FPOP		; write first half
	move.l	8(sp),FPOP		; write second half

	fpidle				; wait for idle state
	move.w	#$5420,FPCMD		; x  / y -> fp0
	ckcir	#$9608			; ready for double
	move.l	12(sp),FPOP		; write first half
	move.l	16(sp),FPOP		; write second half

	fpidle				; wait for idle state
	move.w	#$00A0,FPCMD		; atan(x/y) -> fp0

	fpidle				; wait for idle state
	move.w	#$7400,FPCMD		; fp0 -> double
	ckcir	#$B208			; ready for double
	move.l	FPOP,d0			; get double
	move.l	FPOP,d1
	rts

