Routines |
Prev: 37DA | Up: Map | Next: 3833 |
The address of this routine is found in the table of addresses. It is called via the calculator literal +24 by the routine at asn. It is also called indirectly via fp_calc_2.
This subroutine handles the function ATN X and is the last of the four routines that use the series generator to produce Chebyshev polynomials. It returns a real number between -π/2 and π/2, which is equal to the value in radians of the angle whose tan is X.
The approximation to ATN X is found as follows:
i. The values W and Y are found for three cases of X, such that:
In each case, -1<=Y<=1, as required for the series to converge.
ii. The argument Z is formed, such that:
iii. The series generator is used to produce the required function.
iv. Finally a simple multiplication and addition give ATN X.
|
||||||||
Perform step i.
|
||||||||
atn | 37E2 | CALL re_stack | Use the full floating-point form of X. | |||||
37E5 | LD A,(HL) | Fetch the exponent of X. | ||||||
37E6 | CP $81 | Jump forward for case i: Y=X. | ||||||
37E8 | JR C,SMALL | |||||||
37EA | RST $28 | X | ||||||
37EB | DEFB $A1 | stk_one: X, 1 | ||||||
37EC | DEFB $1B | negate: X, -1 | ||||||
37ED | DEFB $01 | exchange: -1, X | ||||||
37EE | DEFB $05 | division: -1/X | ||||||
37EF | DEFB $31 | duplicate: -1/X, -1/X | ||||||
37F0 | DEFB $36 | less_0: -1/X, (1/0) | ||||||
37F1 | DEFB $A3 | stk_pi_2: -1/X, (1/0), π/2 | ||||||
37F2 | DEFB $01 | exchange: -1/X, π/2, (1/0) | ||||||
37F3 | DEFB $00 | jump_true to CASES for case ii: -1/X, π/2 | ||||||
37F4 | DEFB $06 | |||||||
37F5 | DEFB $1B | negate: -1/X, -π/2 | ||||||
37F6 | DEFB $33 | jump to CASES for case iii: -1/X, -π/2 | ||||||
37F7 | DEFB $03 | |||||||
SMALL | 37F8 | RST $28 | ||||||
37F9 | DEFB $A0 | stk_zero: Y, 0; continue for case i: W=0 | ||||||
Perform step ii.
|
||||||||
CASES | 37FA | DEFB $01 | exchange: W, Y | |||||
37FB | DEFB $31 | duplicate: W, Y, Y | ||||||
37FC | DEFB $31 | duplicate: W, Y, Y, Y | ||||||
37FD | DEFB $04 | multiply: W, Y, Y*Y | ||||||
37FE | DEFB $31 | duplicate: W, Y, Y*Y, Y*Y | ||||||
37FF | DEFB $0F | addition: W, Y, 2*Y*Y | ||||||
3800 | DEFB $A1 | stk_one: W, Y, 2*Y*Y, 1 | ||||||
3801 | DEFB $03 | subtract: W, Y, 2*Y*Y-1=Z | ||||||
Perform step iii, passing to the series generator the parameter '12', and the twelve constants required.
|
||||||||
3802 | DEFB $8C | series_0C: W, Y, Z | ||||||
3803 | DEFB $10,$B2 | |||||||
3805 | DEFB $13,$0E | |||||||
3807 | DEFB $55,$E4,$8D | |||||||
380A | DEFB $58,$39,$BC | |||||||
380D | DEFB $5B,$98,$FD | |||||||
3810 | DEFB $9E,$00,$36,$75 | |||||||
3814 | DEFB $A0,$DB,$E8,$B4 | |||||||
3818 | DEFB $63,$42,$C4 | |||||||
381B | DEFB $E6,$B5,$09,$36,$BE | |||||||
3820 | DEFB $E9,$36,$73,$1B,$5D | |||||||
3825 | DEFB $EC,$D8,$DE,$63,$BE | |||||||
382A | DEFB $F0,$61,$A1,$B3,$0C | |||||||
At the end of the last loop the 'last value' is:
Perform step iv.
|
||||||||
382F | DEFB $04 | multiply: W, ATN X (case i) or W, ATN (-1/X) (cases ii and iii) | ||||||
3830 | DEFB $0F | addition: ATN X (all cases now) | ||||||
3831 | DEFB $38 | end_calc | ||||||
3832 | RET | Finished: 'last value'=ATN X. |
Prev: 37DA | Up: Map | Next: 3833 |