flat assembler
Message board for the users of flat assembler.
Index
> Main > Using the defined operator |
Author |
|
shutdownall 26 Jul 2015, 00:17
I can not check your example - you didn't use the struc operator (is not named struc<t>) - must be a macro. If so, which one ?
I would refer to the manual, "2.3.4 structures" in detail and in general the section "2.2.2 conditional assembly". There is existing a "used" operator as well as an "eqtype" operator which may be useful in this context. What is working with defined operator is check of constants and labels, there maybe restriction on complex data types. This is different here to C language. I use labels in my programs to avoid double definitions in conjunction with defined. |
|||
26 Jul 2015, 00:17 |
|
PeExecutable 26 Jul 2015, 01:16
All include files that come with fasm uses struct.
Code: if ~ defined include_extra_include_file include_extra_include_file equ 1 include 'equates\extra.inc' end if That one worked. (Everything compiles normally again) Last edited by PeExecutable on 26 Jul 2015, 10:04; edited 1 time in total |
|||
26 Jul 2015, 01:16 |
|
revolution 26 Jul 2015, 05:06
The "if defined" is ignored by the preprocessor and both structures get defined regardless. For conditional preprocessing you will need to use something like match.
|
|||
26 Jul 2015, 05:06 |
|
shutdownall 26 Jul 2015, 11:25
PeExecutable wrote: All include files that come with fasm uses struct. Maybe - but not every programmer uses FASM's include files. Could have been something own defined, could have been renamed struc to struct with "fix" directive or something other own defined structure. So at least it would be helpful a piece of code which runs itself in FASM - not just a portion of your code. So struct is a macro and a macro is handled by the preprocessor and for the preprocessor you need conditional preprocessing which is quite different to conditional assembly. It is very useful to go through FASM documentation in a silent hour or so to explore the sometimes hidden features - you could learn much unexpected stuff. I myself detected yesterday that there is a "used" directive - maybe newly added feature in the last years. I am still using version 1.71.01 while I mostly studied the documentation when using the version 1.69.35 or so. |
|||
26 Jul 2015, 11:25 |
|
PeExecutable 26 Jul 2015, 23:46
Thanks for the great tips, I appreciate it. (1.71.01 )
|
|||
26 Jul 2015, 23:46 |
|
shutdownall 27 Jul 2015, 12:38
PeExecutable wrote: Thanks for the great tips, I appreciate it. (1.71.01 ) I use FASM for 8 bit developments (Z80 version) - so support of newer Intel and AMD instructions, 64bit support and some other directives are not so important for me. But I like the general structure and easyness of FASM. |
|||
27 Jul 2015, 12:38 |
|
El Tangas 09 Aug 2015, 02:23
This thread is already a bit cold, but I would like to add my input. People already said this, but let me make it more clear: things like "define", "equ", "macro", "struc", "irps", match", etc. are managed by the preprocessor, they are not affected by "if/end if", this doesn't exist for the preprocessor.
So for the code: Code: struc MyStructure { a dd ? b dd ? } if ~ defined MyStructure struc MyStructure { a dd ? b dd ? c dd ? d dd ? } end if the preprocessor only sees: Code: struc MyStructure { a dd ? b dd ? } struc MyStructure { a dd ? b dd ? c dd ? d dd ? } So the structure will be defined and then redefined, no matter the if/end if Then, comes the assembler, it doesn't see preprocessing stuf, because it has already been preprocessed, defines, equ's, macros, etc replaced by their values. So (I'm not entirely clear on this), the assembler will see: Code: if ~ defined MyStructure <- assembler doesn't understand this end if It will not understand "MyStructure" in that position, because structures can't be placed there. "defined" only works on assembly time variables and constants, meaning labels and numeric variables: Code: ;stuff that "defined" understands: label const at 1 here: nothing=0 So in this case, "const", "here" and "nothing" would be valid for "defined". What I do when I need some conditional preprocessing, is, for example: Code: define Im_defined anything can be here irpv values, Im_defined { common ;stuff to be preprocess only if "Im_defined" exists, for example: irps value, values \{ display \`value,13,10 \} } this code will display: Code: anything can be here If you comment out the define, nothing will happen. |
|||
09 Aug 2015, 02:23 |
|
PeExecutable 22 Aug 2015, 22:11
deleted this post, I found something by searching
|
|||
22 Aug 2015, 22:11 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.