flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > REPT with multiple counters |
Author |
|
l_inc 05 Apr 2013, 22:50
baldr
This is a nice one. It's probably more obvious, but the counters also support string initializers. Unfortunately, not even the complete 32 bit range is supported (I'd prefer consistent 65 bit arithmetic for the preprocessor as well). In such cases I'm always interested in the author's comments, whether the behaviour is desired and whether it can be relied on in macros under consideration of future fasm releases. _________________ Faith is a superposition of knowledge and fallacy |
|||
05 Apr 2013, 22:50 |
|
Tomasz Grysztar 05 Apr 2013, 23:35
Right now the main purpose of this feature is to allow computing multiple expressions with a single REPT.
As for the counter range - in fasm every kind of repetition count, whether it is argument to REPT, REPEAT, TIMES, or value of % or REPT counter, is a 32-bit signed value. |
|||
05 Apr 2013, 23:35 |
|
l_inc 06 Apr 2013, 00:01
Tomasz Grysztar
OK. Thank you for the clarification. _________________ Faith is a superposition of knowledge and fallacy |
|||
06 Apr 2013, 00:01 |
|
l_inc 17 Mar 2015, 14:34
Tomasz Grysztar
It seems I didn't verify the statement regarding 32-bit signed type of arguments for repeat and times last time. How does the following code comply with it? Code: repeat 0xFFFFFFFF if % > 1 break end if display 'Hello',13,10 end repeat The result clearly differs to that after changing the argument to -1. _________________ Faith is a superposition of knowledge and fallacy |
|||
17 Mar 2015, 14:34 |
|
Tomasz Grysztar 17 Mar 2015, 14:46
My mistake, it probably should be an "unsigned" there. I checked the "get_count_value" routine that is used for counts like REPEAT/TIMES arguments, and it certainly gives back a 32-bit unsigned number (it throws an "invalid value" error if the expression gave a negative result). The REPT directive is thus overzealous in its argument checking, I probably wrote that check under the impression that "get_count_value" returns signed value (not that it is a real problem, since REPT with such high count would run out of memory anyway).
|
|||
17 Mar 2015, 14:46 |
|
l_inc 17 Mar 2015, 15:31
Tomasz Grysztar
As for the rept it's rather relevant if larger initialization values are allowed, cause that defines the limits of preprocessor driven calculations. The repeat and times directives do not allow to specify the initial value of the counter anyway. _________________ Faith is a superposition of knowledge and fallacy |
|||
17 Mar 2015, 15:31 |
|
Tomasz Grysztar 17 Mar 2015, 15:56
l_inc wrote: Tomasz Grysztar |
|||
17 Mar 2015, 15:56 |
|
l_inc 17 Mar 2015, 16:38
Tomasz Grysztar
I'm not sure, what you refer to. If it's rept, then the check seems to be there: Code: rept 1 i:$7FFFFFFF { display 'Hello',13,10 } As for the repeat it uses the unsigned range and the initial value specification is rather irrelevant. _________________ Faith is a superposition of knowledge and fallacy |
|||
17 Mar 2015, 16:38 |
|
Tomasz Grysztar 17 Mar 2015, 17:12
Right, there is a check that guards the signed range again, and in general the signed range is assumed everywhere in context of preprocessor. In short: the range for preprocessor's counters is 32-bit signed, while for assembler's counters is 32-bit unsigned.
|
|||
17 Mar 2015, 17:12 |
|
l_inc 17 Mar 2015, 17:23
Tomasz Grysztar
Now that we know, that the preprocessor's counters are handled differently, what was the problem again to let the preprocessor support 65-bit calculations? I mean that would add uniformity. _________________ Faith is a superposition of knowledge and fallacy |
|||
17 Mar 2015, 17:23 |
|
Tomasz Grysztar 17 Mar 2015, 19:45
l_inc wrote: Tomasz Grysztar The range needed to be 32-bit anyway, because changing it to something larger would require more substantial rewrite of macro handling code. I think I chose the signed over the unsigned range for counter bases because REPT directive was intended to provide some expression evaluation abilities to preprocessor, and signed range meant allowing evaluation of negative values. |
|||
17 Mar 2015, 19:45 |
|
l_inc 17 Mar 2015, 22:55
Tomasz Grysztar
Quote: changing it to something larger would require more substantial rewrite of macro handling code Thanks again for the clarification. I'm taking it as is, though I can think of an explanation only in terms of a counter-evidence to [url=nowhere]this[/url] . P.S. Sorry, didn't initially notice it was a nowhere link. I guess you still can see the original version of the post. _________________ Faith is a superposition of knowledge and fallacy |
|||
17 Mar 2015, 22:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.