Dacobi
Dacobi

Reputation: 437

asm ("fldl %0"...) in DOS, Intel syntax?

I'm working on a retro project trying to compile some test code in Borland Turbo C++/DosBox.

I have this function:

double sin(double x){
   asm ("fldl %0;"
        "fsin;"
        "fstpl %0" : "+m"(x));
   return x;
}

I figure it returns the sin value of x, but I'm otherwise lost.

The error is: Undefined symbol 'fldl'

Can anyone explain this function in Intel asm syntax?

I can't figure it out, I've only ever coded 16bit DOS asm code and no floating point.

Kind Regards /Jacob

Upvotes: 0

Views: 647

Answers (1)

Dacobi
Dacobi

Reputation: 437

The problem is that the target CPU must be at least 386.

so the function should be:

double sin(double x){
    asm{
        fld qword ptr [x]
        fsin
        fstp qword ptr [x]
    }
    return x;
}

I've gotten similar code to compile in TASM with .386 after .MODEL "size"

Upvotes: 2

Related Questions