0
 .MODEL SMALL
    .STACK 100h
ASSUME CX:_TEXT, DS:_DATA   
_DATA SEGMENT DWORD PUBLIC 'DATA'   
xparr db 10 dup (?)
TOW DB 2
CHECKER DB 2
XP DB 1
N DB (?)
_DATA ENDS
    .CODE
.386
.387
PUBLIC _XPN
_XPN PROC NEAR
    PUSH BP
    MOV BP,SP
    MOV DI,OFFSET XPARR
    MOV BX,OFFSET XPARR
    INC BX
    FILD 1
    FCOMP [BP+8]
    FSTSW AX
    SAHF
    JE EQUAL
    JBE BELOW
    MOV AX,[BP+4]
    MOV [DI],AX
    FILD TOW
    JMP CHECK 
BELOW:
    MOV [DI],1
    JMP END
EQUAL:
    MOV AX,[BP+4]
    MOV [DI],AX
    JMP END 
CHECK:
    FCOMP [BP+8]
    FSTSW AX
    SAHF
    JBE SECOND
    FLD [DI]
    FMUL WORD PTR [DI]
    FSTSW AX
    FFREE ST
    MOV [BX],AX
    INC DI
    INC BX
    FILD TOW
    FIMUL CHECKER
    FSTSW AX
    FFREE ST
    MOV CHECKER,AX
    FILD CHECKER
    JMP CHECK
SECOND :
    MOV DI,OFFSET XPARR
    MOV N,[BP+8]
SCND :
    FILD N
    FIST
    FSTSW AX
    FFREE ST
    SAHF 
    JZ END
    FILD TOW
    FILD N
    FPREM 
    FILD 1
    FCOMPP 
    FSTSW AX
    SAHF
    JNE notequal
    FLD [DI]
    FMUL XP
    FSTSW AX 
    MOV XP,AX   
    FFREE ST
notequal:   
    FILD 2
    FIDIVR N
    FSTSW AX 
    MOV N,AX
    FFREE ST
    INC DI
    JMP SCND
END :   
        MOV XP,AX
    POP BP 
    RET
    _XPN ENDP
    _TEXT ENDS
    END

嘿,我m trying to calculate x^n by a public function xpn that gets double x and int n so i have to calculate in array x^1 , X^2 , x^4 ..... x^k k<n then i have to multiple xp=1 with array[i] if (n mod 2)=1 if not n=n/2 ,and i=i+1 so somebody can help me because it is not working !! i don知道如何像 qword ptr 那样进行转换,它是 tasm assembley fpu= 浮点单元,我m trying to do : i得到的是 double x 和 int n,我在 xpn x^1,x^2,x^4 中计算....x^k k0 { if n mod 2 = 1 xp=xp*xpn[i] n=n/2 i=i+1 } 所以最后我得到 x^n !!!!!!

4

0 回答 0