Turbo Assembler中FPU栈弹出TWORD类型数据报错的问题求助
fstp Error Hey, I’ve dealt with this exact TWORD issue in Turbo Assembler before—those error messages are super frustrating when you know your logic is right. Let’s walk through the fixes that worked for me:
1. Swap TWORD PTR for DT PTR
Older versions of TASM have better support for DT (the define-type pseudo-instruction for 10-byte long doubles) than the TWORD alias when used as a type override. Change your problematic line to:
fstp dt ptr [BX]
This should immediately get rid of the "Undefined symbol: TWORD" error, since DT is a native TASM identifier for long double storage.
2. Enable x87 Coprocessor Support
Long double operations depend on x87 floating-point instructions, and TASM might not recognize these by default. Add one of these pseudo-instructions at the top of your code:
.8087 ; For older TASM versions targeting 8087 coprocessors ; OR .387 ; If you're targeting 386+ systems with extended coprocessor features
Without this, TASM can’t parse x87-specific types and instructions, leading to that "Argument needs type override" message.
3. Explicitly Define TWORD as DT (For Stubborn Versions)
If the first two fixes don’t stick, your TASM version might not have TWORD pre-defined. Add this line near the top of your code to alias it:
TWORD EQU DT
Now you can use TWORD PTR [BX] if you prefer that syntax, and TASM will recognize it as the 10-byte long double type.
Here’s Your Modified Working Code Snippet
To put it all together, your string_to_float proc should look like this:
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 ... .8087 ; Make sure coprocessor support is enabled mov BX, __DT[BP] fstp dt ptr [BX] ; Use DT PTR for the type override ... string_to_float endp
That should get your long double operations compiling without errors!
内容的提问来源于stack exchange,提问作者BEEET Hvcw

