flat assembler
Message board for the users of flat assembler.
Index
> Main > Question about float point expressions in fasm |
Author |
|
ProMiNick 04 Apr 2018, 05:20
I guess because operators in expression of istruction operands reserved only for integer manipulations. for me it is very convinient: avoiding float everywhere where it is possible it is good.
1st solution: Thou can extend such behavior with macros for all thour cases, but macros dosn`t operate floats natively, so thou`ll have to extract float components (sign,mantissa,fraction) and manipulate on them manually. 2nd solution: or thou could make macros for thour particular case macro mov op1,op2 { local ?f match =float =1 =. =0 =/ =2,op2 \{ mov op1,0.5 ?f equ \} match =?f,?f \{ mov op1,op2 \} } macro dd [val] { local ?f match =float =1 =. =0 =/ =2,op2 \{ dd 0.5 ?f equ \} match =float =1 =/ =2,op2 \{ dd 0.5 ?f equ \} match =?f,?f \{ dd val \} } 2nd solution will increase readability personaly for thou and keep compilation time still fast. |
|||
04 Apr 2018, 05:20 |
|
revolution 04 Apr 2018, 05:47
binwalk wrote: my question is Internally fasm uses a higher precision representation than the FPU supports, so if arbitrary expressions were to be supported then all the operators (+, -, * and /) would have to be coded manually. It is not impossible to do, of course, but it would require having enough need for it and then finding time to code it and test it. |
|||
04 Apr 2018, 05:47 |
|
Tomasz Grysztar 04 Apr 2018, 09:32
In fasm 1 floating point values can only be passed directly to the module that converts them to the binary representation of given size, and thus any computations on them are impossible. On the other hand fasmg has them as a one of the types of values that can be passed around and kept in variables, and there it is possible to evaluate expressions with them.
|
|||
04 Apr 2018, 09:32 |
|
binwalk 10 Apr 2018, 09:01
ProMiNick wrote: I guess because operators in expression of istruction operands reserved only for integer manipulations. for me it is very convinient: avoiding float everywhere where it is possible it is good. Your solution is clear, but it is easy to code it instead of using macro for just this case , now I have to accept that avoiding to use float point in numerical expression where I code |
|||
10 Apr 2018, 09:01 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.