How can I use Floating-Point Instructions Set in DevC++?

Good Day Everyone.

I have managed to use inline assembly in into my project and it runs properly without errors. But I am also required to use floating point instruction set in my project. I usually try to do a simple operation and then gradually make it more complex and keep testing. Unfortunately, the most simplest operation throws errors.
This is the code snippet of the FPU operation I'm trying to execute.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
float PntofIntersec()
{
    float static results = 0.0;
    float num1 = 1.7;
    float num2 = 0.3;
	
    __asm __volatile__("fld %1;"
                       "fld %2;"
                       "fmulp;"
                       "fstp %0;" : "=a" (results) : "a"(num1), "b" (num2) );
                        
    cout << results << endl;     

    return results; 
}


This is the error message I receive after trying to run this operation
1
2
3
4
5
6

Assembler messages:
Error: operand type mismatch for `fld'
Error: operand type mismatch for `fld'
Error: operand type mismatch for `fstp'
 



I also want to mention another problem, after executing this function of the code below, I get the result comes up wrong. The correct answer should be 0x3863CE4BD77C | 62001313994620 but I get (3461076860) as my answer which is totally wrong. I run the asm code separately but both solutions give the same answer. Can anyone See the error?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
unsigned long long int integerCal()
{
    unsigned long int num1 = 0x56BA53;	             // 5683795
    unsigned long int num2 = 0xA67314;	             // 10908436
    unsigned long int num3  = 0x18CBAAED;	     // 416000749
    static unsigned long long int mulResult1 = 0;    // 0x3863CE4BD77C / 62001313994620
    static unsigned long long int mulResult2 = 0;   	
	

        __asm __volatile__( "movl $0x56BA53, %eax;"
		            "imull $0xA67314, %eax;"
                            : "=a"(mulResult) );


    __asm __volatile__( "imull %%ebx, %%eax;" : "=a"(mulResult) : "a" (num1), "b" (num2) );
	
    cout << mulResult << endl;
	
    return mulResult1 or mulResult2;

}




Last edited on
Topic archived. No new replies allowed.