flat assembler
Message board for the users of flat assembler.
Index
> Main > [fasm 1] Precalculated Float 
Author 

revolution
fasm doesn't natively support floating point arithmetic at compile time. Only integer arithmetic is available.
Code: x = 3.0  2.0 ; not valid x = 3  2 ; okay as integers only 

29 Jun 2021, 16:59 

Overclick
Look at Constant1 that trick is working. But why I cannot precalculate all values as integer and use the same trick on them by #f ? Have I precalculate it on virtual or something?
How a macro will help me to solve this out if "struc" is already some sort of macro? I'm confused, show me the path p.s.Seems like it's time to separate forum for fasm1 and fasmg. 

29 Jun 2021, 18:19 

revolution
Overclick wrote: But why I cannot precalculate all values as integer and use the same trick on them by #f ? The assembler computes integer arithmetic after the preprocessor has finished processing the hash symbol. 

29 Jun 2021, 18:26 

Overclick
How to force calculation or delay that bloody hash?


29 Jun 2021, 18:29 

revolution
Overclick wrote: How to force calculation or delay that bloody hash? 

29 Jun 2021, 18:30 

Overclick
What about virtual?


29 Jun 2021, 18:33 

revolution
If you want to go ahead with a macro then it might look like this:
Code: macro convert_to_float input_integer { exponent = bsf input_integer ;... more stuff here dd sign + exponent + mantissa } my_value = 3  2 convert_to_float my_value 

29 Jun 2021, 18:33 

Overclick
Thanks


29 Jun 2021, 18:42 

Overclick
Much easiest way for me to precalculate them inside the code at initialisation stage
Your mathematics is interesting to me anyway. I was thinking to use it for float as alternative to division, but now I don't use it anymore. I'll meditate on it some day. 

29 Jun 2021, 18:50 

revolution
That was the easy part.
It gets tricky when you have fractional parts. Code: v1 = 0.15 v2 = 3.0 dd v1 + v2 ; invalid Code: macro addf float1, float2 { ;some code goes here to do the addition dd sign + exponent + mantissa } 

29 Jun 2021, 18:51 

Roman
Quote:
I not understood macro addf get float1 and float2. But why in macro dd sign + exponent + mantissa ? And not float1 and float2. 

30 Jun 2021, 08:52 

Roman
I think Fasm need implement some new symbol for this problem topic starter.
I am about float values. 

30 Jun 2021, 08:53 

revolution
Roman wrote: I not understood macro addf get float1 and float2. Code: a = 2.0 ; 0x4000_0000_0000_0000 b = 3.0 ; 0x4008_0000_0000_0000 c = 5.0 ; 0x4014_0000_0000_0000 d = a + b ; 0x8008_0000_0000_0000 

30 Jun 2021, 09:39 

idle
exponent = bsf input_integer
d = a + b ; 0x8008_0000_0000_0000 That last value for d is not the float representation for 5.0. You get a bogus result bsf (input_integer) ; embrace to let expressions Also the bias $3fff. Also sign bit. And float format. There are macro to encode 0.etc. Time loss... [/b] 

30 Jun 2021, 14:19 

< Last Thread  Next Thread > 
Forum Rules:

Copyright © 19992020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.