3Dh FN$POWR calculate X to the power of Y
Input Two floating-point arguments on the stack.
Output Floating-point result on the stack.
Description

Returns the result of X ** Y where X and Y are floating-point numbers on the run-time stack. The arguments should be pushed onto the stack in the order X first, then Y. The stack pointer (RTA_SP) will be incremented by 8 after the operation.

Error 247 is returned if:

  • Both arguments are zero
  • X is negative and Y non-integer
  • The result is greater than 9.99999999999E+99

See also: technical manual > utility system services > floating point numbers

Example The following subroutine will return 2 ** 10 in FN_RESULT.
        LDD     RTA_SP:
        SUBD    #16             ;make room for arguments on stack
        STD     RTA_SP:         ;D now has destination for UT$CPYB
        LDX     #16             ;length for copying arguments
        STX     UTW_S0:         ;(copying both together)
        LDX     #FN_Y           ;source address for UT$CPYB
        OS      UT$CPYB         ;copy arguments to stack
        OS      FN$POWR
        LDX     RTA_SP:         ;source address for copying result
        LDD     #8
        STD     UTW_S0:         ;length for copying result
        ADDD    RTA_SP:         ;add 8 to stack pointer
        STD     RTA_SP:         ;restore stack pointer
        LDD     #FN_RESULT      ;destination for copy
        OS      UT$CPYB
        RTS

    FN_Y:                               ;Y first, then X
        DB      0,0,0,0,0,10h,1,0       ;(from low -> high memory)
    FN_X:
        DB      0,0,0,0,0,20h,0,0
    FN_RESULT:
        DS      8
FN_RESULT will now contain the floating-point result 1024.0.
Errors 247 - bad argument in function call