CW6.3 Assembler - Problem with conditional assembly directives

Discussion created by bigmac on Feb 3, 2012
Latest reply on Feb 3, 2012 by sebasira

Hello all,


CW assembler has a rich set of conditional assembly directives.  I typically would utilize something like the following construct to prevent the multiple definition of a particular label -


  ifndef  LABEL_NAME

LABEL_NAME  equ  <expression>



  ifndef  LABEL_NAME


  [<assembly instructions, macros, data, etc>]   ; Optional



These examples seem to work just fine.  However, the problem seems to be when the label refers to a macro definition.  The label name remains undefined, resulting in error messages about duplicate macro definitions.


  include ""    ifndef  ILOP ILOP:     MACRO     ; Reset MCU using illegal opcode          DC.B  $8D          ENDM  endif


 The above does not work if the macro is also defined with the file "".  The only work-around that I so far have been able to find, is to create a dummy label, in addition to the macro name.


  include ""    ifndef  _ILOP _ILOP:    ; Reset MCU using illegal opcodeILOP:     MACRO          DC.B  $8D          ENDM  endif


However, in addition to being unwieldy, this method becomes problematic should the include be not modifiable to provide the dummy variable, e.g. such as "".


I wonder if others, who make extensive use of assembly macros, have previously encountered this problem, and perhaps have an alternative "fix".  Maybe this is a bug in the assembler, that has never been fixed, or perhaps this was intentional in the design of the assembler.