.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
获得双x和int n
并且我在xpn x ^ 1,x ^ 2,x ^ 4 .... x ^ k k0中计算
{
如果n mod 2 = 1
XP = XP * XPN [I]
n = n / 2 i = i + 1
}
所以最后我得到x ^ n !!!!!