flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Use eqtype with numerical constants |
| Author |
|
|
revolution 31 Oct 2026, 20:06
Once 3.14 is stored in x the assembler now considers it just an ordinary 65-bit value. There isn't a way to undo that because the assembler doesn't have any way to know if a value is intended to be interpreted as a float.
Code: macro testMacro var { if var eqtype 1.1 display "This is a float",13,10 else if var eqtype 0 display "This is an integer",13,10 else display "This is not a number",13,10 end if } x = 3.14 testMacro x ; Displays "This is an integer" Last edited by revolution on 31 Oct 2026, 22:41; edited 1 time in total |
|||
|
|
Tomasz Grysztar 31 Oct 2026, 20:55
Yes, as said above, numeric variable/constant in fasm 1.x can only be an integer type (with some variable terms added, if it's an address with registers or relocatable bases), and upon the value assignment a floating-point value is converted into a binary representation and stored as an integer.
In other words, this: Code: x = 3.14 Code: x = 40091EB851EB851Fh I've been aware that this limitation is often contrary to expectations, which is why I designed fasmg to allow variables containing floating-point or string values and marked as such (and also explicit conversions of types). Because of that, fasmg's EQTYPE has been reworked to evaluate expressions and compare types of the results. Therefore with fasm2 your example would work as you expected (after updating the macro to fasmg's "end macro" syntax). On the other hand, this made fasmg's EQTYPE not accept a freeform syntax, which would need to be filtered out with MATCH first. With fasm 1 you can compare sequences of tokens that can be almost anything: Code: macro testMacro seq& { if seq eqtype 1f::'',[0] display "This is of type float::'str',[addr]",13,10 else display "This is not",13,10 end if } testMacro 3.14::'Hello!',[ebx] |
|||
|
|
revolution 31 Oct 2026, 22:49
Code: $ cat test.asm if 3.14 = 40091EB851EB851Fh display 'same thing',13,10 end if $ fasm test.asm flat assembler version 1.73.31 (16384 kilobytes memory) same thing 1 passes, 0 bytes. |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.