Search code examples
assemblytasm

Pop TWORD variable from FPU stack in TASM


I am writing a program in Turbo Assembler which gets a number from console, calculate another number based on it, and prints result onto console.

I have done conversion from string to floating-point number and back through subprograms (I do not think it really matters, just in case). However, I have problem. I have to work with LONG DOUBLE (TWORD, DT) numbers, and I just can not do it! I can do it with DOUBLE (QWORD, DQ) and FLOAT (DWORD, DD) numbers, but no way with TWORD. Okay, just the code (I pass argument through stack, just in case):

locals  __

...

string_to_float proc near
            
arg     __ARGS:word:4 = __ARGSIZE

    __ARG struc
        __BP        dw ?
        __IP        dw ?
        __STRING    dw ? ; string address
        __DT        dw ? ; LONG DOUBLE number address
    __ARG ends

...

    mov BX, __DT[BP]
    fstp tword ptr [BX]

...

When assembling, TASM says:

Undefined symbol: TWORD

Argument needs type override

It points to the very last line of the code I have given here.

There is no problem if I do it, for example, with DOUBLE number, like this:

locals  __

...

string_to_float proc near
            
arg     __ARGS:word:4 = __ARGSIZE

    __ARG struc
        __BP        dw ?
        __IP        dw ?
        __STRING    dw ?
        __DQ        dw ? ; DOUBLE number address
    __ARG ends

...

    mov BX, __DQ[BP]
    fstp qword ptr [BX]

...

What can be done here? I have searched for different names for TWORD, but I have only found, well, TWORD and DT, which I have already known.


Solution

  •     FSTP TBYTE PTR [BX]
    

    In the end checking TD disassembly did help most, even checking the quick reference guide and fstp instruction examples was not enough, the example is wrong there and I overlooked the tbyte ptr defined at page 12 in "Turbo Assembler 5.0 Quick Reference Guide":

    TBYTE PTR expression | Ideal, MASM

    Forces address expression to be 10-byte size