flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > Floating point calculation in fasm? Goto page Previous 1, 2 |
Author |
|
Tomasz Grysztar 16 Sep 2005, 01:19
This would need a separate type of constants for the floats - in fact this would need to make HLL-like typing of the assembler symbols. Otherwise assembler wouldn't be able to remember that "a" was defined as a float value, not talking about storing it internally in different format.
However when I write "a = dword 1.0" I just want the single precision floating point value and so I get it, fitting in 32 bits, and on those 32 bits I can then do any operations (including logical ones). Any typing mechanism you propose would break it. Since this is the assembler, not HLL, it should be clear why I see no other solution than separating the operators - just like there are separated instructions for the integer and floating point operations in machine language. |
|||
16 Sep 2005, 01:19 |
|
revolution 16 Sep 2005, 08:07
Hehe, this would be a mess:
Code: a=dword 1.0 b=qword 2.0 c=tbyte 3.0 ;not allowed with current v1.64 but bear with me. d=4 e=a+b+c+d ;we need type conversions also to properly calcuate the answer madmatt: you are wanting FASM to store extra information about the constants to indicate whether it is integer, SP or DP. Right now FASM only "remembers" the basic 64 bits after conversion of SP or DP. This is why without changes to the storage format FASM cannot "know" what a number like 0x123456789abcdef is supposed to be. If we allow FASM to remember the type then what do we do here: Code: a=dword 1.0 b=a xor 0x80000000 Last edited by revolution on 16 Sep 2005, 08:07; edited 1 time in total |
|||
16 Sep 2005, 08:07 |
|
madmatt 16 Sep 2005, 08:07
I don't know how the internals of fasmw works, so if you say that it couldn't be done easily without major modifications then i"ll have to use other methods. Fortunately I wouldn't use this feature too often, but on a few occasions it would've been sure nice to have. Thanks for taking the time to answer this question.
MadMatt |
|||
16 Sep 2005, 08:07 |
|
Tomasz Grysztar 16 Sep 2005, 10:20
The point here is not that it couldn't be done or that it would be too much work. My point is - as usually when considering some extensions to fasm syntax - to keep the overall clear and simple. Typing is not simple, and there are many places where the behavior would be the choice of language, not just the logical consequence of basic rules. I prefer to keep the minimum set of rules and everything else as simple effects of those rules. And also, as revolution noted, in assembly we should be able to do everything with the binary values we define (the macros I propose work because of it), and any type-conversion etc. would be only the obstacle on the way.
|
|||
16 Sep 2005, 10:20 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.