flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > equ irps argument name |
Author |
|
bitRAKE 07 Apr 2013, 04:41
FASM preprocesses the source file and then assembles the result. It is very important to make a clear distinction between these two realms of FASM. For all intents the preprocessor manipulates only strings. Which includes: MACRO, IRPS, EQU, etc. (see the manual)
The preprocessor doesn't know what IF/ELSE/END IF are - skips right over them looking for something to preprocess. So, you see, something other than what you intend is happening. By the time the IFs are examined by the assembler, all the EQUs have been resolved. The listing tool which comes with FASM might assist at better examining the output at another level. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
07 Apr 2013, 04:41 |
|
alwaysnub 07 Apr 2013, 17:04
Ok its fixed.
Code: macro mTest label,[arg] { CurrentLoop equ 0 irps symb,arg \{ match =0, CurrentLoop \\{ v1 equ symb \\} match =2, CurrentLoop \\{ v2 equ symb \\} rept 1 x:CurrentLoop+1 \\{ CurrentLoop equ x \\} \} CMP v1,v2 } |
|||
07 Apr 2013, 17:04 |
|
baldr 07 Apr 2013, 18:58
alwaysnub,
Due to implicit forward, irps is superfluous. |
|||
07 Apr 2013, 18:58 |
|
alwaysnub 07 Apr 2013, 20:11
ok.. but il stick with it for now.
I'm having a problem thats related to a problem on one of my other posts. I'm trying to add on to an equ, for example: Code: macro JPCOND label,arg { JMPCONDITION equ JN irps symb,arg \{ match ==, symb \\{ JMPCONDITION equ JMPCONDITION\\\#E \\} After debugging, i know the above code results in JMPCONDITION equ JN#E, if i remove the # it puts a space between JN and E, whitch i cant have. I have tried so many combinations of // #, but i cant get it working. Funy how something so simple can be such a pain... |
|||
07 Apr 2013, 20:11 |
|
baldr 07 Apr 2013, 20:42
alwaysnub,
You don't have to try those combinations. You have to understand how (and when) preprocessor removes backslashes. Rule of thumb: match number of backslashes with that of enclosing block ({}, aha). |
|||
07 Apr 2013, 20:42 |
|
l_inc 07 Apr 2013, 20:54
alwaysnub
As a supplement to baldr's comment. You also should understand, that in your code expansion of JMPCONDITION on the right side is mutually exclusive with the concatenation: you can either expand the symbol or concatenate the symbol with E, in which case JMPCONDITION won't be expanded (as it becomes a different symbol JMPCONDITIONE). You can however use the match directive to first expand the symbol, and then concatenate the result of expansion within the match macroblock. _________________ Faith is a superposition of knowledge and fallacy |
|||
07 Apr 2013, 20:54 |
|
alwaysnub 07 Apr 2013, 21:45
Quote: Rule of thumb: match number of backslashes with that of enclosing block ({}, aha). Yes, i understand, but it was not working the way i wanted so i figured i would experiment Quote: you can either expand the symbol or concatenate the symbol with E, in which case JMPCONDITION won't be expanded (as it becomes a different symbol JMPCONDITIONE). Thats a design flaw, theres no reason i cant do both at the same time. hopfully it is addressed in the future releases of fasm. Untill then: Code: match JMPx, JMPCONDITION \{ JMPCONDITION equ JMPx \} Removes the # and results in what i wanted. Thanks guys! |
|||
07 Apr 2013, 21:45 |
|
l_inc 10 Apr 2013, 21:07
alwaysnub
Quote: Thats a design flaw, theres no reason i cant do both at the same time. That's not a design flaw. That's not even a limitation. There's a definition of each directive's and operator's operation. The way you combine them is just not supposed to result (according to those definitions) in what you expect. It's like saying that there's no reason one can't maximize CPU frequency by overclocking and minimize power consumption at the same time. But there is a reason: the things just work like that. Quote: hopfully it is addressed in the future releases of fasm I really doubt that, because there's actually nothing to address in this case. _________________ Faith is a superposition of knowledge and fallacy |
|||
10 Apr 2013, 21:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.