<?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: In Line Assembly in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/In-Line-Assembly/m-p/168050#M5037</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you show the disassembly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without having tried it out (no CW here), I would think your problem is the type long.&lt;/P&gt;&lt;P&gt;Long is a 4 byte type and a "LDD&amp;nbsp; ClockCycles" loads the two most significant bytes.&lt;/P&gt;&lt;P&gt;Try to make ClockCycles a unsigned long or use&amp;nbsp; LDD&amp;nbsp; ClockCycles:2 to read the 2 least significant bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;I believe the problem is that I need to do direct addressing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Direct addressing is for variables in the zero page. Accessing variables on the stack is done with IDX (or IDX1/IDX2) with the SP used as index register. I think the syntax LDD ClockCycles is fine, probably just reads the wrong part of the variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jan 2010 08:35:54 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2010-01-18T08:35:54Z</dc:date>
    <item>
      <title>In Line Assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/In-Line-Assembly/m-p/168049#M5036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I am missing something easy here. I made a function to wait a variable amount of time. My problem is that the D accumulator starts at zero after I tell it to load the ClockCycles variable. I believe the problem is that I need to do direct addressing. To do that I would perform LDD #ClockCycles, but Codewarrior doesn't accept that, and instead loads the address, which puts 0000 in the D accumulator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// ---------------------------------------------&lt;BR /&gt;// VariableWaitAmount -- Pass in the amount of ns to delay, 40 ns min&lt;BR /&gt;// ---------------------------------------------&amp;nbsp;&amp;nbsp;&lt;BR /&gt;void VarWait(long int nsToWait) {&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; long int ClockCycles;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; ClockCycles = nsToWait / 40;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; asm START: LDD ClockCycles&lt;BR /&gt;&amp;nbsp; asm LOOP1: DBNE D, LOOP1&lt;BR /&gt;&amp;nbsp; return;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2010 05:03:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/In-Line-Assembly/m-p/168049#M5036</guid>
      <dc:creator>uflchamp</dc:creator>
      <dc:date>2010-01-18T05:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: In Line Assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/In-Line-Assembly/m-p/168050#M5037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you show the disassembly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without having tried it out (no CW here), I would think your problem is the type long.&lt;/P&gt;&lt;P&gt;Long is a 4 byte type and a "LDD&amp;nbsp; ClockCycles" loads the two most significant bytes.&lt;/P&gt;&lt;P&gt;Try to make ClockCycles a unsigned long or use&amp;nbsp; LDD&amp;nbsp; ClockCycles:2 to read the 2 least significant bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;I believe the problem is that I need to do direct addressing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Direct addressing is for variables in the zero page. Accessing variables on the stack is done with IDX (or IDX1/IDX2) with the SP used as index register. I think the syntax LDD ClockCycles is fine, probably just reads the wrong part of the variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2010 08:35:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/In-Line-Assembly/m-p/168050#M5037</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2010-01-18T08:35:54Z</dc:date>
    </item>
  </channel>
</rss>

