home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / asmlib.zip / SOLVE.DOC < prev    next >
Text File  |  1992-06-13  |  20KB  |  676 lines

  1.  
  2. *********************** MATHEMATICAL SOLUTIONS *****************************
  3.  
  4. ASMLIB's SOLVE subroutines are handy for many number crunching
  5. problems.  Most SOLVE subroutines require a math coprocessor.  In
  6. subroutines requiring a math coprocessor, the coprocessor must have been
  7. initialized with FINIT or FNINIT before calling the subroutine.  See
  8. MathChip in SYSTEM.DOC.  Note that the 80x87 math coprocessors do not
  9. understand unsigned integers.
  10.  
  11.  
  12. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  13.  
  14. C2F:        convert degrees Celcius to degrees Fahrenheit
  15. Source:     f2c.asm
  16.  
  17. 80x87 required
  18.  
  19. Call with:  ST(0) = degrees Celcius
  20. Returns:    ST(0) = degrees Fahrenheit
  21. Uses:       ST(0), 80x87 flags
  22. Example:
  23.  
  24. extrn    c2f:proc
  25.  
  26. .data
  27. c0       dw 100           ; 100 degrees Celcius
  28. f0       dw ?             ; going to store degrees Fahrenheit here
  29.  
  30. .code
  31.          .
  32.          .
  33.          .
  34.          fild   c0        ; load degrees Celcius into ST(0)
  35.          call   c2f       ; returns degrees Fahrenheit in ST(0)
  36.          fistp  f0        ; save degrees Fahrenheit and pop the 8087's stack
  37.  
  38.  
  39.  
  40. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  41.  
  42. CUBEFITF4:  fit a cubic equation to a set of float4 data
  43. CUBEFITF8:  fit a cubic equation to a set of float8 data
  44. CUBEFITI2:  fit a cubic equation to a set of integer2 data
  45. CUBEFITI4:  fit a cubic equation to a set of integer4 data
  46. Source:     cubefit.asm
  47.  
  48. 80x87 required
  49.  
  50.             CubeFit subroutines use the Least Squares method to calculate
  51.             the a, b, c and d coefficients of the equation
  52.  
  53.             y = a + bx + c(x^2) + d(x^3)
  54.  
  55.             which best fits the given data points.  See also QuadFit and
  56.             LineFit.
  57.             The data series at DS:[BX] consists of n sets of x and y
  58.             coordinates.
  59.  
  60. Call with:  DS:[BX] pointing to data series
  61.             CX = number of (x,y) points
  62. Returns:    ST(0) = a
  63.             ST(1) = b
  64.             ST(2) = c
  65.             ST(3) = d
  66. Uses:       entire 80x87 stack
  67. Example:
  68.  
  69. extrn   cubefiti2:proc
  70.  
  71. .data
  72. points  dw 1,6           ; first (x,y) coordinate pair: x0 = 1, y0 = 6
  73.         dw 2,17          ; x1 = 2, y1 = 17
  74.         dw 5,86          ; x2 = 5, y2 = 86
  75.         dw 4,57          ; x3 = 4, y3 = 57
  76.         dw 3,34          ; x4 = 3, y4 = 34
  77. n equ ($-points) shr 2   ; number of coordinate pairs (5 in this case)
  78.  
  79. .code
  80. ; program fragment assumes DS:@data
  81.         .
  82.         .
  83.         .
  84.         lea   bx,points  ; point to data series
  85.         mov   cx,n       ; 5 data points
  86.         call  cubefiti2  ; returns ST(0) = a
  87.                          ;         ST(1) = b
  88.                          ;         ST(2) = c
  89.                          ;         ST(3) = d
  90.  
  91.  
  92.  
  93. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  94.  
  95. DEG2RAD:    convert degrees of arc to radians
  96. Source:     deg2rad.asm
  97.  
  98. 80x87 required
  99.  
  100. Call with:  ST(0) = degrees of arc
  101. Returns:    ST(0) = radians
  102. Uses:       80x87 stack - ST(6) and ST(7) are lost
  103. Example:
  104.  
  105. include asm.inc
  106. extrn   deg2rad:proc
  107.  
  108. .data
  109. deg     dw 180             ; dumb example - everyone knows this is pi radians
  110.  
  111. .code
  112. ; program fragment assumes DS:@data
  113.         .
  114.         .
  115.         .
  116.         fild   deg         ; load degrees into ST(0)
  117.         call   deg2rad     ; it comes back with ST(0) = radians
  118.  
  119.  
  120.  
  121. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  122.  
  123. F2C:        convert degrees Fahrenheit to degrees Celcius
  124. Source:     f2c.asm
  125.  
  126. 80x87 required
  127.  
  128. Call with:  ST(0) = degrees Fahrenheit
  129. Returns:    ST(0) = degrees Celcius
  130. Uses:       ST(0), 80x87 flags
  131. Example:
  132.  
  133. extrn    f2c:proc
  134.  
  135. .data
  136. f0       dw 212           ; 212 degrees Farenheit
  137. c0       dw ?             ; going to store degrees Celcius here
  138.  
  139. .code
  140. ; program fragment assumes DS:@data
  141.          .
  142.          .
  143.          .
  144.          fild   f0        ; load degrees Fahrenheit into ST(0)
  145.          call   f2c       ; returns degrees Celcius in ST(0)
  146.          fistp  c0        ; save degrees Celcius and pop the 8087's stack
  147.  
  148.  
  149.  
  150. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  151.  
  152. FACTORIAL:  calculates the factorial of an integer
  153. Source:     factori.asm
  154.  
  155. 80x87 required
  156.  
  157. Call with:  AX = signed integer value
  158. Returns:    ST(0) = factorial of the integer value
  159.             Note: factorials get very large with relatively small integers
  160. Uses:       ST(0); coprocessor stack is pushed, ST(7) is lost
  161. Example:
  162.  
  163. extrn   factorial:proc
  164.  
  165. .code
  166.         .
  167.         .
  168.         .
  169.         mov   ax,6          ; gonna calculate the factorial of 6
  170.         call  factorial
  171.  
  172.  
  173.  
  174. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  175.  
  176. FPRIMEI2:   calculate the derivative of a polynomial function
  177. Source:     fprimei2.asm
  178.  
  179. 80x87 NOT required
  180.  
  181. Call with:  DS:[SI] pointing to equation coefficients; all coefficients
  182.                must be 2-byte signed integers
  183.             CX = order of polynomial (i. e., a quadratic function
  184.                is a second-order polynomial, so CX = 2)
  185. Returns:    nothing
  186. Uses:       nothing
  187. Example:
  188.  
  189. extrn   fprimei2:proc
  190.  
  191. .data
  192.  
  193. fx      dw 2,0,3,2,0,5      ; the function y = 2+3*(x^2)+2*(x^3)+5*(x^5)
  194.  
  195. .code
  196. ; program fragment assumes DS:@data
  197.         .
  198.         .
  199.         .
  200.         mov     cx,5        ; fifth order polynomial
  201.         lea     si,fx       ; point to f(x) coefficients (2-byte integers)
  202.         call    fprimei2    ; calculate derivative of the function
  203.                             ; results:
  204.                             ; fx=0, fx+2=6, fx+4=6, fx+6=0, fx+8=25, fx+10=0
  205.  
  206.  
  207. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  208.  
  209. FPRIMEF4:   calculate the derivative of a polynomial function
  210. Source:     fprimef4.asm (mathchip.asm, i2tof4.asm, mulf4.asm)
  211.  
  212. 80x87 NOT required
  213.  
  214. Call with:  DS:[SI] pointing to equation coefficients; all coefficients
  215.                must be float4 values
  216.             CX = order of polynomial (i. e., a quadratic function
  217.                is a second-order polynomial, so CX = 2)
  218.  
  219.             FPrimeF4 uses the 80x87 if present, or uses ASMLIB's 80x87
  220.             emulation subroutines if no 80x87 is in the system.  Registerd
  221.             ASMLIB users with ASMLIB source code may eliminate the 80x87
  222.             emulation code by re-assembling with the NOEM conditional
  223.             assembly directive.
  224.  
  225. Returns:    nothing
  226. Uses:       nothing
  227. Example:
  228.  
  229. extrn   fprimef4:proc
  230.  
  231. .data
  232.  
  233. fx      dd 2.2,0.0,3.5,2.0,0.0,5.1
  234.                             ; the function y = 2.2+3.5*(x^2)+2*(x^3)+5.1*(x^5)
  235.  
  236. .code
  237. ; program fragment assumes DS:@data
  238.         .
  239.         .
  240.         .
  241.         mov     cx,5        ; fifth order polynomial
  242.         lea     si,fx       ; point to f(x) coefficients (float4 values)
  243.         call    fprimef4    ; calculate derivative of the function
  244.  
  245.  
  246. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  247.  
  248. FVALUE:     calculate the future value of a given present value and
  249.             equal periodic payments
  250. Source:     fvalue.asm (xtothey.asm)
  251.  
  252. 80x87 required
  253.  
  254. Call with:  DS:[SI] pointing to an ASMLIB Financial data structure
  255.             (see FINDATA.INC).  The pv, n, i, and pmt data must be
  256.             current before calling fvalue.
  257. Returns:    updates fv in FINDATA data structure; future value also
  258.             returned in ST(0)
  259. Uses:       80x87 stack
  260. Evample:
  261.  
  262. include  asm.inc
  263. include  findata.inc
  264.  
  265. extrn    fvalue:proc
  266.  
  267. .data
  268.  
  269. case1    findata <12,.0525,100.0,10.0,> ; n = 12 periods
  270.                                         ; i = .0525 (5.25% interest rate per n)
  271.                                         ; present value = 100
  272.                                         ; 10 = payment per n period
  273.  
  274. .code
  275. ; program fragment assumes DS:@data
  276.          .
  277.          .
  278.          .
  279.          lea  si,case1
  280.          call fvalue                    ; calculate future value; update
  281.                                         ; fv in case1
  282.  
  283. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  284.  
  285. LINEFITF4:  fit a line equation to a series of float4 data points
  286. LINEFITF8:  fit a line equation to a series of float8 data points
  287. LINEFITI2:  fit a line equation to a series of i2 data points
  288. LINEFITI4:  fit a line equation to a series of i4 data points
  289. Source:     linefit.asm
  290.  
  291. 80x87 required
  292.  
  293.             LineFit subroutines use the Least Squares method to calculate
  294.             the a and b coefficients of the equation
  295.  
  296.             y = a + bx
  297.  
  298.             which best fits the given data points.  See also CubeFit
  299.             and QuadFit.
  300.             The data series at DS:[BX] consists of n sets of x and y
  301.             coordinates.
  302.  
  303. Call with:  DS:[BX] pointing to data series
  304.             CX = number of (x,y) points
  305. Returns:    ST(0) = a
  306.             ST(1) = b
  307.             ST(2) = Σx
  308.             ST(3) = Σxx
  309.             ST(4) = Σy
  310.             ST(5) = Σxy
  311. Uses:       entire 80x87 stack
  312. Example:
  313.  
  314. extrn   linefiti2:proc
  315.  
  316. .data
  317. points  dw 1,5           ; first (x,y) coordinate pair
  318.         dw 3,12          ; x1 = 3, y1 = 12
  319.         dw 7,24          ; x2 = 7, y2 = 24
  320.         dw 5,17          ; x3 = 5, y3 = 17
  321.         dw 10,33         ; x4 = 10, y4 = 33
  322. n equ ($-points) shr 2   ; number of coordinate pairs (5 in this case)
  323.  
  324. .code
  325. ; assumes DS:@data
  326.         .
  327.         .
  328.         .
  329.         lea   bx,points  ; point to data series
  330.         mov   cx,n       ; 5 data points
  331.         call  linefiti2  ; returns a in ST(0) and b in ST(1)
  332.  
  333.  
  334.  
  335. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  336.  
  337. NORMF4, NORMF4b:   normalize a float4 array
  338. Source:            small & medium: normf4.asm (maxf4.asm)
  339.                    huge: normf4.asm (maxf4.asm, lowDS2hi.asm)
  340.  
  341. NORMF8, NORMF8b:   normalize a float8 array
  342. Source:            small & medium: normf8.asm (maxf8.asm)
  343.                    huge: normf8.asm (maxf8.asm, lowDS2hi.asm)
  344.  
  345. 80x87 required
  346.  
  347. Call with:  ES:[DI] pointing to the numeric array
  348.             CX = number of values in the array
  349.             ST(0) = number to normalize the array to
  350.             normf?b: BX = bytes between data points
  351.             normf4 assumes BX = 4, norm f8 assumes BX = 8
  352.  
  353.             NormF4 and NormF8 assume that the maximum value of the data
  354.             is greater than zero.  I have used these subroutines
  355.             to scale data upward or downward, for example, to convert
  356.             from raw data to percent-of-maximum data.
  357.  
  358. Returns:    ST(0) = scaling factor
  359. Uses:       ST(0); ST(7) and ST(6) are pushed off the coprocessor stack
  360. Example:
  361.  
  362. extrn   normf4:proc
  363.  
  364. .data
  365.  
  366. hundred dw 100            ; convert all data to percent-of-peak
  367.  
  368. .code
  369.         .
  370.         .
  371.         .
  372.         mov    ax,f4seg   ; segment where the values are stored
  373.         mov    es,ax
  374.         mov    di,f4ptr   ; now ES:[DI] points to the data
  375.         mov    cx,1488    ; half-hourly data for a month
  376.         fild   hundred    ; make the maximum value 100
  377.         call   normf4     ; normalize the data
  378.  
  379.  
  380.  
  381. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  382.  
  383. NPVALUE:    calculate net present value of an uneven cash flow
  384. Source:     npvalue.asm (xtothey.asm)
  385.  
  386. 80x87 required
  387.  
  388. Call with:  DS:[SI] pointing to ASMLIB's FINDATA data structure
  389.             ES:[BX] pointing to float4 cash flow data
  390.             n, i, and fv in FINDATA must be current before calling NPValue,
  391.             and there must be at least n cash flows
  392. Returns:    updates pv in FINDATA
  393.             ST(0) = present value
  394. Uses:       80x87 stack
  395. Example:
  396.  
  397. include   asm.inc
  398. include   findata.inc
  399.  
  400. extrn     npvalue:proc
  401.  
  402. .data
  403. case1     findata <30,.105,,,0.0>     ; 30 payments, 10.5% interest, fv = 0.0
  404. payments  dd 10 dup (80.0)            ; need 30 payments for this example
  405.           dd 10 dup (95.0)
  406.           dd 10 dup (103.0)
  407.  
  408. .code
  409. ; program fragment assumes DS:@data
  410.           .
  411.           .
  412.           .
  413.           push   ds
  414.           pop    es                  ; ES = DS
  415.           assume es:@data
  416.           lea    bx,payments
  417.           lea    si,case1
  418.           call   npvalue
  419.  
  420.  
  421.  
  422. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  423.  
  424. PSOLVEF4:   solve a polynomial equation for y, given x; float4 equation
  425.             coefficients
  426. Source:     psolvef4.asm
  427.  
  428. PSOLVEF8:   solve a polynomial equation for y, given x; float8 equation
  429.             coefficients
  430. Source:     psolvef8.asm
  431.  
  432. PSOLVEI2:   solve a polynomial equation for y, given x; 2-byte integer
  433.             equation coefficients
  434. Source:     psolvei2.asm
  435.  
  436. PSOLVEI4:   solve a polynomial equation for y, given x; 4-byte integer
  437.             equation coefficients
  438. Source:     psolvei4.asm
  439.  
  440. 80x87 required for all psolve subroutines
  441.  
  442. Call with:  DS:[SI] pointing to equation coefficients
  443.             CX = n (order of the equation, i. e., a quadratic equation
  444.                is a second-order polynomial, so CX = 2)
  445.             ST(0) = x value
  446. Returns:    ST(0) = y value
  447. Uses:       most coprocessor registers
  448. Example:
  449. ; I want to calculate y for the equation
  450. ; y = 12 + 2x + 17(x**2) + 4(x**3)
  451.  
  452. extrn   psolvei2:proc
  453.  
  454. .data
  455. fx      dw 12,2,17,4
  456. n       equ 3              ; third-order equation
  457. x       dd 0.85
  458.  
  459. .code
  460. ; program fragment assumes DS:@data
  461.         .
  462.         .
  463.         .
  464.         lea     si,fx      ; DS:[SI] points to equation coefficients
  465.         mov     cx,n       ; a third-order polynomial
  466.         fld     x          ; find y given x
  467.         call    psolvei2   ; returns y in register ST(0)
  468.  
  469.  
  470.  
  471. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  472.  
  473. PVALUE:     calculate the present value of an even cash flow
  474. Source:     pvalue.asm (xtothey.asm)
  475.  
  476. 80x87 required
  477.  
  478. Call with:  DS:[SI] pointing to FINDATA data structure
  479.             n, i, pmt and fv must be updated before calling
  480.             pvalue.
  481. Returns:    updates pv in FINDATA data structure
  482.             ST(0) = present value
  483. Uses:       80x87 stack
  484. Example:
  485.  
  486. include  asm.inc
  487. include  findata.inc
  488.  
  489. extrn    pvalue:proc
  490.  
  491. .data
  492.  
  493. case1    findata <12,.0525,,10.0,0.0>   ; n = 12 periods
  494.                                         ; i = .0525 (5.25% interest rate per n)
  495.                                         ; present value unknown
  496.                                         ; payment per n period = 10
  497.                                         ; future value = 0
  498.  
  499. .code
  500. ; program fragment assumes DS:@data
  501.          .
  502.          .
  503.          .
  504.          lea  si,case1
  505.          call pvalue                    ; calculate present value; update
  506.                                         ; pv in case1
  507.  
  508.  
  509. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  510.  
  511. QUADFITF4:  fit a quadratic equation to a series of float4 data points
  512. QUADFITF8:  fit a quadratic equation to a series of float8 data points
  513. QUADFITI2:  fit a quadratic equation to a series of i2 data points
  514. QUADFITI4:  fit a quadratic equation to a series of i4 data points
  515. Source:     quadfit.asm
  516.  
  517. 80x87 required
  518.  
  519.             QuadFit subroutines use the Least Squares method to calculate
  520.             the a, b and c coefficients of the equation
  521.  
  522.             y = a + bx + c(x^2)
  523.  
  524.             which best fits the given data points.  See also CubeFit and
  525.             LineFit.
  526.             The data series at DS:[BX] consists of n sets of x and y
  527.             coordinates.
  528.  
  529. Call with:  DS:[BX] pointing to data series
  530.             CX = number of (x,y) points
  531. Returns:    ST(0) = a
  532.             ST(1) = b
  533.             ST(2) = c
  534. Uses:       entire 80x87 stack
  535. Example:
  536.  
  537. extrn   quadfiti2:proc
  538.  
  539. .data
  540. points  dw 1,6           ; first (x,y) coordinate pair: x0 = 1, y0 = 6
  541.         dw 2,17          ; x1 = 2, y1 = 17
  542.         dw 5,86          ; x2 = 5, y2 = 86
  543.         dw 4,57          ; x3 = 4, y3 = 57
  544.         dw 3,34          ; x4 = 3, y4 = 34
  545. n equ ($-points) shr 2   ; number of coordinate pairs (5 in this case)
  546.  
  547. .code
  548. ; assumes DS:@data
  549.         .
  550.         .
  551.         .
  552.         lea   bx,points  ; point to data series
  553.         mov   cx,n       ; 5 data points
  554.         call  quadfiti2  ; returns a in ST(0), b in ST(1) and c in ST(2)
  555.  
  556.  
  557.  
  558. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  559.  
  560. RAD2DEG:    convert radians to degrees of arc
  561. Source:     rad2deg.asm
  562.  
  563. 80x87 required
  564.  
  565. Call with:  ST(0) = radians
  566. Returns:    ST(0) = degrees of arc
  567. Uses:       80x87 stack - ST(6) and ST(7) are lost
  568. Example:
  569.  
  570. include asm.inc
  571. extrn   rad2deg:proc
  572.  
  573. .data
  574. rad     dd 3.14159        ; dumb example - everyone knows this is 180 degrees
  575.  
  576. .code
  577. ; program fragment assumes DS:@data
  578.         .
  579.         .
  580.         .
  581.         fld    rad         ; load radians into ST(0)
  582.         call   rad2deg     ; it comes back with ST(0) = degrees
  583.  
  584.  
  585.  
  586. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  587.  
  588. SAMP2POP:   convert sample standard deviation to population standard
  589.             deviation; used with StdDev subroutines.
  590. Source:     samp2pop.asm
  591.  
  592. 80x87 required
  593.  
  594. Call with:  ST(0) = sample standard deviation
  595.             CX = n (number of data points)
  596. Returns:    ST(0) = population standard deviation
  597. Uses:       ST(0); ST(7), ST(6) and ST(5) are lost
  598. Example:    see StdDev series subroutines
  599.  
  600.  
  601. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  602.  
  603. STDDEVF4:   calculate standard deviation of a float4 data series 
  604. STDDEVF8:   calculate standard deviation of a float8 data series 
  605. STDDEVI2:   calculate standard deviation of an i2 data series 
  606. STDDEVI4:   calculate standard deviation of an i4 data series 
  607. Source:     small & medium: stddev.asm
  608.             huge: stddev.asm (lowDS2hi.asm)
  609.  
  610. 80x87 required
  611.  
  612. Call with:  ES:[DI] pointing to data series
  613.             CX = number of values
  614.             Note that integer values are signed integers
  615. Returns:    if CF = 1, CX = 0
  616.             if CF = 0, ST(0) = standard deviation
  617.             The value returned by StdDev subroutines is the sample standard
  618.             deviation S; population standard deviation SP is calculated from
  619.             sample standard deviation with this formula:
  620.  
  621.             SP = S * SQRT((n - 1) / n)
  622.  
  623. Uses:       CF, coprocessor registers
  624. Example:
  625.  
  626. extrn   stddevf4:proc       ; my data series is in float4 format
  627. extrn   samp2pop:proc       ; I want the result as a
  628.                             ; population standard deviation
  629. .code
  630.         .
  631.         .
  632.         .
  633. ; the program has established a series of float4 values, and I need the
  634. ; standard deviation of the series
  635.         mov   es,series_segment
  636.         mov   bx,series_offset
  637.         mov   cx,1600        ; a whole bunch of data
  638.         call  stddevf4       ; ST(0) = sample standard deviation
  639.  
  640. ; the standard deviation returned by StdDev subroutines is the sample
  641. ; standard deviation.  Use samp2pop to convert to population standard
  642. ; deviation
  643.         call  samp2pop       ; ST(0) = population standard deviation
  644.  
  645. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  646.  
  647. XTOTHEY:    calculates x to the y power (x^y)
  648. Source:     xtothey.asm
  649.  
  650. 80x87 required
  651.  
  652. Call with:  ST(0) = x, ST(1) = y
  653. Returns:    ST(0) = x^y, coprocessor stack popped
  654. Uses:       coprocessor stack
  655. Example:
  656.  
  657. extrn   xtothey:proc
  658.  
  659. .data
  660.  
  661. x       dd 17.4
  662. y       dd .3
  663.  
  664. .code
  665.         mov    ax,@data         ; make the x & y data available
  666.         mov    ds,ax            ; normally you would not need to do this
  667.         assume ds:@data         ; after the startup code unless the program
  668.                                 ; has messed with DS
  669.         .
  670.         .
  671.         .
  672.         fld    y                ; ST(0) = exponent
  673.         fld    x                ; ST(0) = x, ST(1) = exponent
  674.         call   xtothey          ; calculate x**y
  675.  
  676.