![]() |
Routines |
Prev: 36AF | Up: Map |
Used by the routine at to_power.
The address of this routine is found in the table of addresses. It is called indirectly via fp_calc_2.
This subroutine handles the function EXP X and is the first of four routines that use the series generator to produce Chebyshev polynomials.
The approximation to EXP X is found as follows:
|
||||||||
exp | 36C4 | RST $28 | X | |||||
Perform step i.
|
||||||||
36C5 | DEFB $3D | re_stack: X (in full floating-point form) | ||||||
36C6 | DEFB $34 | stk_data: X, 1/LN 2 | ||||||
36C7 | DEFB $F1,$38,$AA,$3B,$29 | |||||||
36CC | DEFB $04 | multiply: X/LN 2=Y | ||||||
Perform step ii.
|
||||||||
36CD | DEFB $31 | duplicate: Y, Y | ||||||
36CE | DEFB $27 | int: Y, INT Y=N | ||||||
36CF | DEFB $C3 | st_mem_3: Y, N (mem-3 holds N) | ||||||
Perform step iii.
|
||||||||
36D0 | DEFB $03 | subtract: Y-N=W | ||||||
Perform step iv.
|
||||||||
36D1 | DEFB $31 | duplicate: W, W | ||||||
36D2 | DEFB $0F | addition: 2*W | ||||||
36D3 | DEFB $A1 | stk_one: 2*W, 1 | ||||||
36D4 | DEFB $03 | subtract: 2*W-1=Z | ||||||
Perform step v, passing to the series generator the parameter '8' and the eight constants required.
|
||||||||
36D5 | DEFB $88 | series_08: Z | ||||||
36D6 | DEFB $13,$36 | |||||||
36D8 | DEFB $58,$65,$66 | |||||||
36DB | DEFB $9D,$78,$65,$40 | |||||||
36DF | DEFB $A2,$60,$32,$C9 | |||||||
36E3 | DEFB $E7,$21,$F7,$AF,$24 | |||||||
36E8 | DEFB $EB,$2F,$B0,$B0,$14 | |||||||
36ED | DEFB $EE,$7E,$BB,$94,$58 | |||||||
36F2 | DEFB $F1,$3A,$7E,$F8,$CF | |||||||
At the end of the last loop the 'last value' is 2**W.
Perform step vi.
|
||||||||
36F7 | DEFB $E3 | get_mem_3: 2**W, N | ||||||
36F8 | DEFB $38 | end_calc | ||||||
36F9 | CALL FP_TO_A | The absolute value of N mod 256 is put into the A register. | ||||||
36FC | JR NZ,N_NEGTV | Jump forward if N was negative. | ||||||
36FE | JR C,REPORT_6_2 | Error if ABS N>+FF. | ||||||
3700 | ADD A,(HL) | Now add ABS N to the exponent. | ||||||
3701 | JR NC,RESULT_OK | Jump unless e>+FF. | ||||||
Report 6 - Number too big.
|
||||||||
REPORT_6_2 | 3703 | RST $08 | Call the error handling routine. | |||||
3704 | DEFB $05 | |||||||
N_NEGTV | 3705 | JR C,RSLT_ZERO | The result is to be zero if N<-255. | |||||
3707 | SUB (HL) | Subtract ABS N from the exponent as N was negative. | ||||||
3708 | JR NC,RSLT_ZERO | Zero result if e less than zero. | ||||||
370A | NEG | Minus e is changed to e. | ||||||
RESULT_OK | 370C | LD (HL),A | The exponent, e, is entered. | |||||
370D | RET | Finished: 'last value' is EXP X. | ||||||
RSLT_ZERO | 370E | RST $28 | Use the calculator to make the 'last value' zero. | |||||
370F | DEFB $02 | delete (the stack is now empty) | ||||||
3710 | DEFB $A0 | stk_zero: 0 | ||||||
3711 | DEFB $38 | end_calc | ||||||
3712 | RET | Finished, with EXP X=0. |
Prev: 36AF | Up: Map |