<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic CW6.3 Assembler - Problem with conditional assembly directives in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW6-3-Assembler-Problem-with-conditional-assembly-directives/m-p/202754#M7670</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CW assembler has a rich set of conditional assembly directives.&amp;nbsp; I typically would utilize something like the following construct to prevent the multiple definition of a particular label -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp;&amp;nbsp;ifndef&amp;nbsp; LABEL_NAME&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;LABEL_NAME&amp;nbsp; equ&amp;nbsp; &amp;lt;expression&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp;&amp;nbsp;ifndef&amp;nbsp; LABEL_NAME&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;LABEL_NAME:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; [&amp;lt;assembly instructions, macros, data, etc&amp;gt;]&amp;nbsp;&amp;nbsp; ; Optional&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;These examples seem to work just fine.&amp;nbsp; However, the problem seems to be when the label refers to a macro &lt;SPAN style="text-decoration: underline;"&gt;definition&lt;/SPAN&gt;.&amp;nbsp; The label name remains undefined, resulting in error messages about duplicate macro definitions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp; include "908_macros.inc"&amp;nbsp;&amp;nbsp;&amp;nbsp; ifndef&amp;nbsp; ILOP ILOP:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MACRO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Reset MCU using illegal opcode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DC.B&amp;nbsp; $8D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDM&amp;nbsp; endif&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The above does not work if the macro is also defined with the file "908_macros.inc".&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp; include "908_macros.inc"&amp;nbsp;&amp;nbsp;&amp;nbsp; ifndef&amp;nbsp; _ILOP _ILOP:&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Reset MCU using illegal opcodeILOP:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MACRO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DC.B&amp;nbsp; $8D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDM&amp;nbsp; endif&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 "derivative.inc".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder if others, who make extensive use of assembly macros, have previously encountered this problem, and perhaps have an alternative "fix".&amp;nbsp; Maybe this is a bug in the assembler, that has never been fixed, or perhaps this was intentional in the design of the assembler.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Feb 2012 15:31:36 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2012-02-03T15:31:36Z</dc:date>
    <item>
      <title>CW6.3 Assembler - Problem with conditional assembly directives</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW6-3-Assembler-Problem-with-conditional-assembly-directives/m-p/202754#M7670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CW assembler has a rich set of conditional assembly directives.&amp;nbsp; I typically would utilize something like the following construct to prevent the multiple definition of a particular label -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp;&amp;nbsp;ifndef&amp;nbsp; LABEL_NAME&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;LABEL_NAME&amp;nbsp; equ&amp;nbsp; &amp;lt;expression&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp;&amp;nbsp;ifndef&amp;nbsp; LABEL_NAME&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;LABEL_NAME:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; [&amp;lt;assembly instructions, macros, data, etc&amp;gt;]&amp;nbsp;&amp;nbsp; ; Optional&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new,courier';"&gt;&amp;nbsp; endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;These examples seem to work just fine.&amp;nbsp; However, the problem seems to be when the label refers to a macro &lt;SPAN style="text-decoration: underline;"&gt;definition&lt;/SPAN&gt;.&amp;nbsp; The label name remains undefined, resulting in error messages about duplicate macro definitions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp; include "908_macros.inc"&amp;nbsp;&amp;nbsp;&amp;nbsp; ifndef&amp;nbsp; ILOP ILOP:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MACRO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Reset MCU using illegal opcode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DC.B&amp;nbsp; $8D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDM&amp;nbsp; endif&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The above does not work if the macro is also defined with the file "908_macros.inc".&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp; include "908_macros.inc"&amp;nbsp;&amp;nbsp;&amp;nbsp; ifndef&amp;nbsp; _ILOP _ILOP:&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Reset MCU using illegal opcodeILOP:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MACRO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DC.B&amp;nbsp; $8D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDM&amp;nbsp; endif&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 "derivative.inc".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder if others, who make extensive use of assembly macros, have previously encountered this problem, and perhaps have an alternative "fix".&amp;nbsp; Maybe this is a bug in the assembler, that has never been fixed, or perhaps this was intentional in the design of the assembler.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 15:31:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW6-3-Assembler-Problem-with-conditional-assembly-directives/m-p/202754#M7670</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-02-03T15:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: CW6.3 Assembler - Problem with conditional assembly directives</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW6-3-Assembler-Problem-with-conditional-assembly-directives/m-p/202755#M7671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you, I'm facing the same problem since many years ago... I always need to create a label for every macro definition. That's in CW 3.1, 4.6 and also 6.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe a solution or fix can help us both!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2012 20:15:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW6-3-Assembler-Problem-with-conditional-assembly-directives/m-p/202755#M7671</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2012-02-03T20:15:07Z</dc:date>
    </item>
  </channel>
</rss>

