<?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 Re: [Starting User] Problem with the inline assembly in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126968#M438</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&amp;gt;I still don't know how to allocate memory in HCS08 assembly...&lt;BR /&gt;&amp;gt;So that it could be recognized by the C compiler.&lt;BR /&gt;&lt;BR /&gt;Actually the point is that for the HC08 you have to differentiate between variables (memory) allocated in the zero page, and variables allocated outside of it.&lt;BR /&gt;In the SMALL memory model (which I guess you are using) variables are extended (say non zero page allocated) by default. So if you want to allocate some into the zero page so that a DBNZ can use it (and not just a LDA), then use the following syntax:&lt;BR /&gt;&lt;BR /&gt;#pragma DATA_SEG SHORT ZERO_PAGE&lt;BR /&gt;// assuming you prm file maps ZERO_PAGE&lt;BR /&gt;// to a memory area &amp;lt;= 0xFF&lt;BR /&gt;unsigned char zero_page_var;&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;BR /&gt;unsigned char default_allocated_var;&lt;BR /&gt;&lt;BR /&gt;You can now use with inline assembly instructions requiring direct (say zero page) addressing mode.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Aug 2006 23:47:33 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2006-08-23T23:47:33Z</dc:date>
    <item>
      <title>[Starting User] Problem with the inline assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126961#M431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everybody,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My probleme is very simple to explain. I hope it will not be harder to solve.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm develloping a very little function that needs to go very fast. Knowing that, I decide to write it directly in assembly code. My problem is that whenever I try to use global variables in this function (inside the asm brackets), the compiler sends the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Error: C18700 Unknown Opcode Operand Combination."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is part of my code : &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;unsigned char ucSampleIdx;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void IsrDecode (void){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; __asm{ &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dbnz ucSampleIdx, FRAMING_ERROR&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FRAMING_ERROR:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; rti&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for your help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2006 14:56:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126961#M431</guid>
      <dc:creator>Barth</dc:creator>
      <dc:date>2006-08-17T14:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: [Starting User] Problem with the inline assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126962#M432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have a couple of question before I can answer here. It looks like the compiler consider your inline assembler instruction as invalid.&lt;/P&gt;&lt;P&gt;Which processor are you targeting (HC08, HC12, Coldfire, EPPC, ...)?&lt;BR /&gt;How is FRAMING_ERROR defined?&lt;BR /&gt;How is ucSampleIdx defined (or declared)?&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2006 17:45:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126962#M432</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-08-17T17:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: [Starting User] Problem with the inline assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126963#M433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks for your fast answer !&lt;BR /&gt;&lt;BR /&gt;I am currently using a HCS08 microcontroler&lt;BR /&gt;&lt;BR /&gt;The ucSampleIdx variable is defined before my first function (out of any brackets) as follows:&lt;BR /&gt;&lt;BR /&gt;unsigned char ucSampleIdx&lt;BR /&gt;&lt;BR /&gt;The FRAMING_ERROR label is only defined by the compiler/assembler and is designed just one instruction later.&lt;BR /&gt;&lt;BR /&gt;Thx again&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2006 22:00:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126963#M433</guid>
      <dc:creator>Barth</dc:creator>
      <dc:date>2006-08-17T22:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: [Starting User] Problem with the inline assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126964#M434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Barth:&lt;BR /&gt;&lt;BR /&gt;It may or may not be the problem, but there you have a space between "ucSampleIdx," and "FRAMING_ERROR" in your assembly instruction (at least in your original post). That would be an illegal syntax for a dbnz instruction.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2006 03:55:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126964#M434</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-08-18T03:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: [Starting User] Problem with the inline assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126965#M435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thank you !!&lt;BR /&gt;&lt;BR /&gt;It seems like it is an adressing mode problem.&lt;BR /&gt;I am trying to use EXT adressing mode when it is not accepted.&lt;BR /&gt;&lt;BR /&gt;That way I already solved a part of my problem, paying more attention to the documentation.&lt;BR /&gt;&lt;BR /&gt;But now I wish to use another instruction (namely branch if bit is clear, brclr), it gives me the same kind of error:&lt;BR /&gt;&lt;BR /&gt;Unknown Opcode Operand Combination: Opc.: BRCLR/Dst.: SP8/Src.: Bit0&lt;BR /&gt;&lt;BR /&gt;for a function defined like that.&lt;BR /&gt;&lt;BR /&gt;void function(void){&lt;BR /&gt;&lt;BR /&gt;unsigned char ucStatusTmp = ucStatus;&lt;BR /&gt;&lt;BR /&gt; __asm{&lt;BR /&gt; brclr 0,ucStatusTmp,WAIT_SYNCHRO_CLK&lt;BR /&gt;WAIT_SYNCHRO_CLK:RTI&lt;BR /&gt;}&lt;BR /&gt;}&lt;P&gt;Message Edited by Barth on &lt;SPAN class="date_text"&gt;2006-08-18&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:00 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2006 12:58:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126965#M435</guid>
      <dc:creator>Barth</dc:creator>
      <dc:date>2006-08-18T12:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: [Starting User] Problem with the inline assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126966#M436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Barth, this one is easier.&lt;BR /&gt;&lt;BR /&gt;The variable "ucStatusTmp" is defined local to the function, so it should therefore be allocated on the stack. The only addressing mode available to the BRCLR instruction is direct (page-zero) addressing, so there is no way to address a variable on the stack (even if the stack is in page-zero).&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2006 15:53:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126966#M436</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-08-18T15:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: [Starting User] Problem with the inline assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126967#M437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks to both of you I solved it all.&lt;BR /&gt; I still don't know how to allocate memory in HCS08 assembly... So that it could be recognized by the C compiler.&lt;BR /&gt;&lt;BR /&gt;But anyway It is already a great thing that I get my application working.&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Aug 2006 16:25:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126967#M437</guid>
      <dc:creator>Barth</dc:creator>
      <dc:date>2006-08-19T16:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: [Starting User] Problem with the inline assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126968#M438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&amp;gt;I still don't know how to allocate memory in HCS08 assembly...&lt;BR /&gt;&amp;gt;So that it could be recognized by the C compiler.&lt;BR /&gt;&lt;BR /&gt;Actually the point is that for the HC08 you have to differentiate between variables (memory) allocated in the zero page, and variables allocated outside of it.&lt;BR /&gt;In the SMALL memory model (which I guess you are using) variables are extended (say non zero page allocated) by default. So if you want to allocate some into the zero page so that a DBNZ can use it (and not just a LDA), then use the following syntax:&lt;BR /&gt;&lt;BR /&gt;#pragma DATA_SEG SHORT ZERO_PAGE&lt;BR /&gt;// assuming you prm file maps ZERO_PAGE&lt;BR /&gt;// to a memory area &amp;lt;= 0xFF&lt;BR /&gt;unsigned char zero_page_var;&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;BR /&gt;unsigned char default_allocated_var;&lt;BR /&gt;&lt;BR /&gt;You can now use with inline assembly instructions requiring direct (say zero page) addressing mode.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Aug 2006 23:47:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Starting-User-Problem-with-the-inline-assembly/m-p/126968#M438</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-08-23T23:47:33Z</dc:date>
    </item>
  </channel>
</rss>

