flat assembler
Message board for the users of flat assembler.

Index > Main > Why can't I assign dt

Author
Thread Post new topic Reply to topic
asmdemon



Joined: 18 Jan 2004
Posts: 97
Location: Virginia Beach, VA
asmdemon 01 Mar 2005, 18:28
i have this code that works:
Code:
fp_real dt ? ; 80-bit floating point number
    

but when i want to assign it with a value:
Code:
fp_real dt 0 ; 80-bit floating point number
    

i get an error. i can compile tword pointer instructions but if i want to define data i have to use dq and dw like this:
Code:
fp_real dw 0
fp_real_2 dq 0
    

Is this a but or builtin?

_________________
It is better to be on the right side of the devil than in his path.
Post 01 Mar 2005, 18:28
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 01 Mar 2005, 18:41
It accepts floating point values only, so it should be:
Code:
fp_real dt 0.0    

or
Code:
fp_real dt 0f    
Post 01 Mar 2005, 18:41
View user's profile Send private message Visit poster's website Reply with quote
asmdemon



Joined: 18 Jan 2004
Posts: 97
Location: Virginia Beach, VA
asmdemon 01 Mar 2005, 23:30
ah, sorry bout that and thanx for the fast reply
Post 01 Mar 2005, 23:30
View user's profile Send private message Visit poster's website Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 02 Mar 2005, 00:23
Speaking of floating point (new-bie question). How do you assign and output an 80bit value like that.

mov [fp_val], st0
but how would you pass it to say a wsprintf function or the console?
Post 02 Mar 2005, 00:23
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 02 Mar 2005, 09:05
you can't use usual integer "mov" instruction to copy a whole 80bit FPU register. If you want to store a FPU register into memory, you must use FPU instructions:
Code:
fst [fp_val]    
or
Code:
 fstp [fp_val]    
depending on whether you want to keep the FPU stack top itself or discard it.

An optimization tip: if you want to copy FPU values from memory to memory, you should better avoid FPU instruction unless you need to do some floating point calculations. For only copying them, use integer (or MMX/SSE...) instructions.
Code:
;This examples copies an 80bit value from memory in [esi] to [edi]
mov eax,[esi]
mov edx,[esi+4]
mov cx,[esi+8]
mov [edi],eax
mov [edi+4],edx
mov [edi+8],cx
    

You can naturally loop this instruction cluster for copying arrays. But I recommend you to align/use your 80bit fp values as 12byte (or even 16byte) values, thus you may replace the "mov cx,[esi+8]" by "mov ecx,[esi+8]" which speed/size optimizes this a bit. When you need it super fast, try considering MMX/SSE with dqword alignment, but anyway, supper fast fp_copying should try to avoid 80bit values, since they are a bit difficult to handle outside the FPU stack.
Post 02 Mar 2005, 09:05
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.