Search code examples
nasmx87

nasm rejects fst tword [mem] --- bug?


fst tword [mem] generates a compilation error under nasm (generates "error: invalid combination of opcode and operands").

fst qword [mem] is accepted by nasm.

fstp tword [mem] and fstp qword [mem] are both accepted by nasm.

Is this a bug in nasm?


Solution

  • From Intel's manual:

    FST/FSTP—Store Floating Point Value
    
    Opcode   Instruction  64-Bit   Compat/Leg  Description
                          Mode     Mode
    ----------------------------------------------------------------------
    D9 /2    FST m32fp   Valid     Valid       Copy ST(0) to m32fp.
    DD /2    FST m64fp   Valid     Valid       Copy ST(0) to m64fp.
    DD D0+i  FST ST(i)   Valid     Valid       Copy ST(0) to ST(i).
    D9 /3    FSTP m32fp  Valid     Valid       Copy ST(0) to m32fp and pop register stack.
    DD /3    FSTP m64fp  Valid     Valid       Copy ST(0) to m64fp and pop register stack.
    DB /7    FSTP m80fp  Valid     Valid       Copy ST(0) to m80fp and pop register stack.
    DD D8+i  FSTP ST(i)  Valid     Valid       Copy ST(0) to ST(i) and pop register stack.
    

    As you can see, there's no m80fp (i.e. tword) variant of FST, but there is for FSTP.