using_20the_20fscale_20instruction
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
using_20the_20fscale_20instruction [2018/03/31 13:19] – external edit 127.0.0.1 | using_20the_20fscale_20instruction [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
=====Using the fscale instruction===== | =====Using the fscale instruction===== | ||
- | //by Tony Tooth, January 2016//\\ \\ Randall Hyde's book "The Art of Assembly Language" | + | //by Tony Tooth, January 2016. Edited by Tony Tooth April 2018//\\ \\ Randall Hyde's book "The Art of Assembly Language" |
- | ---- | + | |
- | \\ {{fscale.jpg}}\\ \\ //Edit by Richard Russell, January 2016://\\ \\ An alternative way of computing the exponential function in BB4W v6 assembly language is to call the internal EXP routine, which is exposed via the **@fn%()** jump table, as follows (it uses **fscale** internally): | + | <code bb4w> |
+ | DEF FN_fractpower(num, | ||
+ | LOCAL pass&, res | ||
+ | |||
+ | PRIVATE Fract%, P% | ||
+ | |||
+ | num = 1.0*num : pow = 1.0*pow | ||
+ | |||
+ | IF Fract% = 0 THEN | ||
+ | DIM P% 1000 | ||
+ | |||
+ | FOR pass& = 0 TO 2 STEP 2 | ||
+ | [opt pass& | ||
+ | .Fract% | ||
+ | |||
+ | finit | ||
+ | fld tbyte [^num] | ||
+ | fld1 | ||
+ | fxch st1 | ||
+ | fyl2x ; | ||
+ | fld tbyte [^pow] | ||
+ | fmulp st1, | ||
+ | fld st0 ;Make a copy 0f what's at st0, so st1 & st0 are the same number | ||
+ | frndint | ||
+ | fsub st1, | ||
+ | fxch st1 ;Exchange st1 with st0 | ||
+ | f2xm1 ; | ||
+ | | ||
+ | faddp st1, | ||
+ | | ||
+ | fstp st1 ;Throw away st1 | ||
+ | fstp tbyte [^res] ;Answer is at st0 | ||
+ | |||
+ | ret | ||
+ | ] | ||
+ | NEXT pass& | ||
+ | ENDIF | ||
+ | |||
+ | CALL Fract% | ||
+ | |||
+ | = res | ||
+ | </ | ||
+ | |||
+ | //Edit by Richard Russell, January 2016://\\ \\ An alternative way of computing the exponential function in BB4W v6 assembly language is to call the internal EXP routine, which is exposed via the **@fn%()** jump table, as follows (it uses **fscale** internally): | ||
+ | |||
+ | <code bb4w> | ||
@% = &1415 | @% = &1415 | ||
REPEAT | REPEAT | ||
Line 32: | Line 77: | ||
CALL X% | CALL X% | ||
= y | = y | ||
+ | </ | ||
+ |
using_20the_20fscale_20instruction.1522502390.txt.gz · Last modified: 2024/01/05 00:16 (external edit)