flat assembler
Message board for the users of flat assembler.
Index
> Main > Inconsistent symbol processing & probable bug |
Author |
|
revolution 07 Aug 2015, 03:57
Code: ! equ 1 ! db 2 ;<--- the same as "1 db 2" |
|||
07 Aug 2015, 03:57 |
|
gmg1812 07 Aug 2015, 11:54
True, my error regarding equ's (that was pretty stupid of me). But why is
! db 1 ; OK ^ db 2 ; OK @ db 3 ; OK while % db 1 ; is an invalid use of symbol? p.10 of the documentation states that "The symbols other than symbol characters and quoted strings can be used as names, so are also called the name symbols," which allows @ ! and ^ but what about %? It is not a "symbol character". Since $ and ? alone have special uses, I understand those errors, but perhaps the documentation should be updated to make that clear when discussing names, especially as ?x is an OK name, as is x$. If % has a special use, what is it? |
|||
07 Aug 2015, 11:54 |
|
shutdownall 07 Aug 2015, 12:39
Some symbols are used for numeric expressions - some for other purposes.
$1000 = 0x1000 = 1000h = 4096 ($=hex value) %10001111 = 10001111b = 8fh (%=binary value) 123o = 1010011b = 0x53 (o=octal value) % has another meaning as repeat counter. See section 1.2.4 numerical expressions in the manual for details. The following chars are symbol characters and have a special meaning and can be found in the TABLES.INC of the FASM source: Code: symbol_characters db 27 db 9,0Ah,0Dh,1Ah,20h,'+-/*=<>()[]{}:,|&~#`;\' |
|||
07 Aug 2015, 12:39 |
|
l_inc 07 Aug 2015, 12:41
gmg1812
Quote: but perhaps the documentation should be updated to make that clear when discussing names What the documentation isn't very good about is using the word symbol for what should actually be called token. Still the documentation defines what a symbol is. It should be clear however that reserved symbols cannot become names. dword is a symbol, but not a symbol character and not a quoted string. Still it cannot become a name of an assembly time constant/variable, cause it's reserved by the assembler for other uses. The same is true for instance for numbers (note the difference between $? and ?$). And for the symbols ?, $ and % as well. x$ is a symbol and it's not reserved, hence it can be used as a name. The above mentioned reserved symbols aren't reserved for the preprocessor and can therefore become names of preprocessor constants or macros. But the same way the reserved symbol include cannot become a name ( macro include {} fails). On the other hand it can become an assembly time constant name, cause it's not reserved by the assembler: Code: x equ include x = 5 if include = 5 display 'Works as expected',13,10 end if Quote: If % has a special use, what is it? 1.2.4 Numerical expressions wrote: There are also some special symbols that can be used inside the numerical expression. First is $ [...] The other one is %, which is the number of current repeat in parts of code that are repeated using some special directives (see 2.2) and zero anywhere else. _________________ Faith is a superposition of knowledge and fallacy |
|||
07 Aug 2015, 12:41 |
|
El Tangas 08 Aug 2015, 00:47
In other news, I just found out that FASM treats the hex number prefix 0x, alone, as zero.
Code: if 0x = 0 display '0x is zero!' end if |
|||
08 Aug 2015, 00:47 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.