flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Interesting idea for macro repetition Goto page 1, 2, 3 Next |
Author |
|
mike.dld 19 Feb 2005, 18:24
Do you mean we could define jump tables with this directive?
|
|||
19 Feb 2005, 18:24 |
|
Tomasz Grysztar 19 Feb 2005, 18:49
It depends on what do you exacly mean by "jump tables". The proposed "breed" directive uses an arbitrarily given value for the repeat count, it have to be specified directly. If you make some jump table by couting some given items, you have to use the standard fasm's techniques. But if you wanted to make some jump table just by directly giving the count of labels, then "breed" would be useful for you.
|
|||
19 Feb 2005, 18:49 |
|
JohnFound 19 Feb 2005, 21:02
Hi.
The idea to have some iteractive operator in preprocessor is very good. I have only some thoughts: 1. Is it be possible to use "breed" in macroses or only constant (and "fix") are allowed: Code: macro MyMacro count { breed count nop } MyMacro 5 2. What about: Code: breed DEBUG include "debug.asm" 3. Definitely we need in preprocessor all powerfull operators from assembling stage, like: if, repeat, aritmethics. Now we have similar functionality, but with different names. Don't you though about some more common solution - for example "if", "repeat" and "times" to be processed both in preprocessor and assembling stages, depending on parameters - for example, if the values are known in preprocessor - why not to process the statement in preprocessor? Example: Code: repeat one, two, three ; because preprocessor have no arithmetics %: end repeat DEBUG equ TRUE if DEBUG eq TRUE ; as far as DEBUG is symbolic constant, its value is known at preprocessing stage, so "if" can be executed. include 'debug.asm' end if Of course I don't actually know whether all this is possible in FASM architecture. Regards |
|||
19 Feb 2005, 21:02 |
|
Tomasz Grysztar 19 Feb 2005, 21:11
1. As you already know, macro parameters are replaced before doing anything else, even before "fix" - so this will work as expected, since "breed" will meet just the 5 value when it is processed.
2. Yes, this will also work - everything that follows "breed" is preprocessed in a standard way after duplicating, so any preprocessor directive is allowed as macros are. Even "breed" nesting is possible (however % gets replaced everywhere by the first "breed", I don't know could I improve it, but it's different from how the "times" nesting works). 3. No, such mixing would make it all backward-incompatible and even unpredicatable. |
|||
19 Feb 2005, 21:11 |
|
JohnFound 19 Feb 2005, 21:27
Privalov wrote: 3. No, such mixing would make it all backward-incompatible and even unpredicatable. Well, yes, you are probably right - the compatibility is important. Also, the idea to name with different names preprocessor operators and assembler equivalents have some advantages - this will make the source code more readable and unambiguous. Anyway, "breed" is excelent idea and I can only acclaim it. Quote: (the error handling might need also to be corrected to work with the breed-generated lines, since they have zeroed the field that normally contains the name of macro) Could you explain more detailed? Any solution? Regards. |
|||
19 Feb 2005, 21:27 |
|
Tomasz Grysztar 19 Feb 2005, 21:33
The command line version use to this field to display the name of macro followed by number of macro line when displaying error info. They will probably crash on a "breed"-generated line, since it has zero pointer there. The solution is simple - check for zero pointer and display only line number (which will be number of "breed"-generated duplicate).
|
|||
19 Feb 2005, 21:33 |
|
JohnFound 19 Feb 2005, 21:58
Ah, it is clear now. Thank you.
Regards. |
|||
19 Feb 2005, 21:58 |
|
Tomasz Grysztar 19 Feb 2005, 22:20
Another idea: maybe it would be better to make it not replace anything by default, but let you specify a name for counter symbol when you need it.
So something like: Code: breed 7 db % would keep the % unchanged, only make 7 duplicates of line; while Code: breed [counter] 7 db counter would replace "counter" symbol with the number of each copy. But I don't have an idea for any nicer syntax for this setting yet. |
|||
19 Feb 2005, 22:20 |
|
beppe85 19 Feb 2005, 22:29
Cool.
To avoid introducing another kwyword, I could suggest this: (@ means AT) breed 7 @ counter db counter |
|||
19 Feb 2005, 22:29 |
|
Tomasz Grysztar 19 Feb 2005, 22:33
There might be a macro called @ and then "breed 7 @ ..." would just duplicate this macro. That's why I tried to invent some syntax with specifying the name of counter symbol before the actual count.
|
|||
19 Feb 2005, 22:33 |
|
Tomasz Grysztar 20 Feb 2005, 13:49
The additional parameters, maybe in the square brackets before the count, as I proposed above, might be also available to specify a few different counter symbols with different some options, like counting from 0 instead of 1 or formatting the number differently, etc.
This idea needs to mature before I consider implementing it oficially (to quick decisions may lead to breaking compatibility later, when better solutions are invented, and I try to avoid such things with fasm*). But feel free to play with it, since the implementation, as given in my first post, is really simple and should be also easy to modify by anyone. And I'm now going back to the 64-bit object output implementation. * Though there was one case when I failed, it was version 1.20 when I changed the way of defining macro blocks. But these were still "early" development stages. |
|||
20 Feb 2005, 13:49 |
|
MCD 21 Feb 2005, 10:48
Privalov wrote:
I think this is very wise, but anyway, nice ideas. (Why not adding some stuff to the preprocessor while you're at?). But, please avoid ambiguous syntax elements, like the % you have proposed. Having the same symbol for both the preprocessor and the parser really can confuse. Anyway, I would be interested in where you got the word "breed" from for repetitions _________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||
21 Feb 2005, 10:48 |
|
vid 21 Feb 2005, 14:22
yes, i think there is plenty of not used symbols, and if you use "%" then if you want to generate "%" for assembly-time repeats you would have to fix it somehow
|
|||
21 Feb 2005, 14:22 |
|
beppe85 21 Feb 2005, 16:39
MCD wrote: Anyway, I would be interested in where you got the word "breed" from for repetitions I was also wondering about. The only place I've heard this word was from Nirvana. I asked to a dictionary, and seems that 'breed' in this case means 'proliferate'. _________________ "I assemble, therefore I am" If you got some spare time, visit my blog: http://www.beppe.theblog.com.br/ and sign my guestmap |
|||
21 Feb 2005, 16:39 |
|
Tomasz Grysztar 21 Feb 2005, 16:44
Yes, I have used this word, because this directive, as opposed to "times", which just does the multiple processing of a line, creates a physical duplicates of line. The "clone" word might also be appropriate, however the clones are supposed to be identical, while those lines might actually differ (because of the counting symbols).
|
|||
21 Feb 2005, 16:44 |
|
Tomasz Grysztar 21 Feb 2005, 16:50
vid wrote: yes, i think there is plenty of not used symbols, and if you use "%" then if you want to generate "%" for assembly-time repeats you would have to fix it somehow That's why I go into the direction of specifying the name for counter symbol for each "breed" (or not specifying at all when you don't need it) - this would also prevent problems with accessing different counter levels when nesting "breeds". |
|||
21 Feb 2005, 16:50 |
|
pelaillo 21 Feb 2005, 19:02
Quote:
This is good ! I agree with MCD about the naming: "for" seems a better/unambiguous/classic/used term to refer to this feature. |
|||
21 Feb 2005, 19:02 |
|
vid 22 Feb 2005, 03:23
i like breed, let's reserve for until it will really be capable of real for.
|
|||
22 Feb 2005, 03:23 |
|
THEWizardGenius 24 Feb 2005, 23:23
Is this going to be included in future versions of FASM? It doesn't look like we need to vote on it... Go ahead and think about it all you want, but I'm going to add it to MY second copy of FASM, which I call "tweaked FASM"; I add all tweaks that you suggest but don't put into official FASM releases, to tweaked FASM... I love FASM tweaks, maybe I'll post my "tweaked FASM" for you to play with... it doesn't have anything of my own because I don't know how to make up my own tweaks, but whenever you or someone else posts a tweaked version I like, I add it. I put instructions for all tweaks into a text file so when new version of FASM comes out I can add it to that one. Maybe I'll post the text file...
|
|||
24 Feb 2005, 23:23 |
|
Goto page 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.