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

hey im 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 dont know how to make the Conversion like qword ptr and it is tasm assembley fpu= floating point unit again what im trying to do : im getting double x and int n and i`m calculating in 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 } so at the end i get x^n !!!!!

Deeb Andrawis
  • 13
  • 2
  • 7
  • You've posted a large amount of ASM code and a vague statement about what you're trying to do. I don't see a question here, or even a good explanation of the problem you're trying to solve. Please edit to provide a description of what you're having trouble with, and ask a specific question about the problem. Thanks. – Ken White Jan 28 '13 at 01:19
  • hey i`m trying to calculate x^n y public function xpn that gets double x and int n so i have to out in array x^1 , X^2 , x^4 ..... x^k k – Deeb Andrawis Jan 28 '13 at 01:52
  • **Edit your question** as I asked in my last comment, to add that information there where it belongs instead of adding it as a comment that people won't see. Your question needs to be improved if you want to get help here. (And, once again, you need to *actually ask a specific question*. "it is not working" means nothing to anyone but you, because you haven't explained what "not working" means, and we can't read your screen or your mind from here.) – Ken White Jan 28 '13 at 01:54
  • Coding the functionality of `void f(double *a, double b, int c) { while (c--) { *a++=b;b*=b; }}` should not take much more than 10 lines of assembler. – Aki Suihkonen Jan 28 '13 at 09:06
  • i don`t know y it is not writing what i want : again what i`m trying to do : i`m getting double x and int n and i`m calculating in 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 } so at the end i get x^n !!!!! and aki no it is not like that – Deeb Andrawis Jan 28 '13 at 10:55
  • is it right FILD 1 or i have to make mov av,1 fild ax ???? – Deeb Andrawis Jan 28 '13 at 15:20

0 Answers0