flat assembler
Message board for the users of flat assembler.
Index
> Windows > Floating point hex converter |
Author |
|
Jack 27 Oct 2005, 11:28
try inputing 3.1415926535897932384626433832795 your prog shows 4000C90FDA912CE9480B when it should 4000C90FDAA22168C23(4)
|
|||
27 Oct 2005, 11:28 |
|
Tomasz Grysztar 27 Oct 2005, 12:22
And when you do
Code: dt 3.1415926535897932384626433832795 |
|||
27 Oct 2005, 12:22 |
|
Jack 27 Oct 2005, 23:31
sorry for the late reply Tomasz, I did not compile the source but used the executable to test.
|
|||
27 Oct 2005, 23:31 |
|
FrozenKnight 28 Oct 2005, 10:27
have ypu tried pushing hta value onto the stack as a constant?
|
|||
28 Oct 2005, 10:27 |
|
Tomasz Grysztar 28 Oct 2005, 12:16
Push as what type of fp value? You can push 32-bit one freely, for the 64-bit there's no single instruction that would do it for you, but you can use the "double" feature of extended "invoke" (read this!)
As for the 80-bit values that were shown above, there is also no instruction that would push the on the stack for you. If for some reason you really want to push the "tbyte" value on the stack, you can do it this way: Code: macro pusht value { virtual at 0 dt value local lo,mid,hi load lo dword from 0 load mid dword from 4 load hi word from 8 end virtual push word hi push dword mid push dword lo } ; example: pusht 3.1415926535897932384626433832795 Of course you can easily adapt it for 64-bits if the "double" feature is not enough for you. Last edited by Tomasz Grysztar on 28 Oct 2005, 13:32; edited 2 times in total |
|||
28 Oct 2005, 12:16 |
|
LocoDelAssembly 28 Oct 2005, 13:18
The macro is correct? It's pushing 6 bytes instead of 10.
(I'm not correcting you, I just don't sure about this) [edit] Code: format PE GUI 4.0 entry start macro pusht value { virtual at 0 dt value local lo, mid, hi ; Now added "mid" load lo dword from 0 load mid dword from 4 load hi word from 8 end virtual push word hi push dword mid push dword lo } ; example: start: pusht 3.1415926535897932384626433832795 add esp, 10 ret [edit]Better I corrected the locals to not confuse nobody[/edit] Last edited by LocoDelAssembly on 28 Oct 2005, 17:50; edited 2 times in total |
|||
28 Oct 2005, 13:18 |
|
Tomasz Grysztar 28 Oct 2005, 13:31
Oh, you're right. Corrected it.
|
|||
28 Oct 2005, 13:31 |
|
LocoDelAssembly 28 Oct 2005, 13:36
jajajajaja, both corrected this at the same time
[edit] all of you use the Tomasz's code, I forgot to put mid on local[/edit] |
|||
28 Oct 2005, 13:36 |
|
FrozenKnight 28 Oct 2005, 16:05
I'm not too familar with the macro's yet, and as such i'm a little reculant to use them at times. currently i perfer.
Code: push 040091EB8h push 051EB851Fh ;3.14( i was too lazy to try that whole long decimal becidedes i know a better way to get pi from the fpu BTW is there someone who knows where i can find a turt for useing FASM macros? i'm having a little troubble understanding them. |
|||
28 Oct 2005, 16:05 |
|
Tomasz Grysztar 28 Oct 2005, 19:28
The shortest sample without macros:
Code: virtual at 0 dq 3.14 load low dword from 0 load high dword from 4 end virtual push high push low Hope this example helps you understand how fasm's assembler module facilities work (the macros themselves are something different, the macro posted earlier was designed just to automatically generate such sequence of assembler commands like the above). |
|||
28 Oct 2005, 19:28 |
|
madmatt 28 Oct 2005, 22:23
question about the virual macro code, does the virtual macro generate any code? or maybe just temporary code?
|
|||
28 Oct 2005, 22:23 |
|
Tomasz Grysztar 28 Oct 2005, 22:40
"virtual" is not a macro, it's assembler's directive. Everything inside the "virtual" block is not put into output file, but it is generated as a temporary code in memory just for the time of assembly (so you can load values like here).
|
|||
28 Oct 2005, 22:40 |
|
madmatt 29 Oct 2005, 05:07
Allright, I understand now, thanks.
|
|||
29 Oct 2005, 05:07 |
|
FrozenKnight 05 Nov 2005, 05:11
Thanks Tomasz Grysztar that is what i have been trying to figure out.
i really need to learn these precompiler directive and macros. i wish someone would make a turtorial on the macros becasue they are really confuseing as they are. |
|||
05 Nov 2005, 05:11 |
|
FrozenKnight 26 Aug 2006, 22:26
I know this post is kind of old but i was wondering why my program gives a diffrent value for 3.1415926535897932384626433832795 (4000C90FDA912CE9480B) than the fldpi (4000C90FDAA22168C235) or the value in fasm. this is a small problem that has confused me reciently.
|
|||
26 Aug 2006, 22:26 |
|
UCM 26 Aug 2006, 22:36
Probably it's because the "fldpi" has more/less accuraccy in the mantissa.
|
|||
26 Aug 2006, 22:36 |
|
vid 27 Aug 2006, 09:18
maybe also because of inaccurate conversion routine of FASM
|
|||
27 Aug 2006, 09:18 |
|
Tomasz Grysztar 31 Aug 2006, 09:06
fasm fed with "3.1415926535897932384626433832795" string gives the same value as FLDPI. Its conversions are quite accurate, since it uses internally 128-bit floating point format to do the calculations.
|
|||
31 Aug 2006, 09:06 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.