<?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>8-bit MicrocontrollersのトピックRe: AN3496</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AN3496/m-p/202482#M16640</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Roberto,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keep in mind that more powerful macros can be written&amp;nbsp;with CW assembler (not the inline version), than are available in C.&amp;nbsp; The LMBD macro would appear sufficiently complex that a function may need to be used in lieu of a macro.&amp;nbsp; Of course this will be somewhat slower than the assembly code macro, as will most code written in C.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would appear that the LMBD macro takes the form it does so that the same number of execution cycles are required, independent of the return value.&amp;nbsp; This may have to be foregone, as the C compiler will likely generate different assembly code than the macro.&amp;nbsp; The equivalent C function would probably have the following form -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;byte LMBD( byte val){  if (val &amp;gt;= 0x10) {    if (val &amp;gt;= 0x40) {      if (val &amp;gt;= 0x80)  return 7;      else              return 6;    }    else {      if (val &amp;gt;= 0x20)  return 5;      else              return 4;    }  }  else {    if (val &amp;gt;= 0x04) {      if (val &amp;gt;= 0x08)  return 3;      else              return 2;    }    else {      if (val &amp;gt;= 0x02)  return 1;      else              return 0;    }  }}&lt;/PRE&gt;&lt;P&gt;If you can tolerate significant variation in the execution cycles, depending on the output value, the following inline assembly code should produce a similar output&amp;nbsp;to the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;byte LMBD( byte val){  __asm {        LDA  val;        LDX  #8;LOOP1:  DECX;        LSLA;        BCC  LOOP1;        STX  val;  }  return val;}&lt;/PRE&gt;&lt;P&gt;After cursory examination, it would appear that the equivalent of INT_OBJ should be setup as a C structure for each interrupt source.&amp;nbsp; INT_objtab would then become an array of structures.&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 May 2010 23:55:19 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2010-05-20T23:55:19Z</dc:date>
    <item>
      <title>AN3496</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AN3496/m-p/202481#M16639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking for another an, I've found on Freescale's site&lt;BR /&gt;AN3496 - « A Software Approach to Using Nested Interrupts in HCS08 ».&lt;BR /&gt;I think it is very interesting.&lt;BR /&gt;I'm trying to insert it in a project, but I've some trouble.&lt;BR /&gt;First: could be a "c" project (with a .asm file &amp;amp; .h file to interface it)?&lt;BR /&gt;Second: how could I declare&amp;nbsp; INT_OBJ in C? more general: how colud I&lt;BR /&gt;insert/transform a "MACRO" (written in asm) in "something else" written in C?&lt;BR /&gt;I don't know how implement LMBD macro...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 May 2010 19:55:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AN3496/m-p/202481#M16639</guid>
      <dc:creator>roberto_m</dc:creator>
      <dc:date>2010-05-20T19:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: AN3496</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/AN3496/m-p/202482#M16640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Roberto,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keep in mind that more powerful macros can be written&amp;nbsp;with CW assembler (not the inline version), than are available in C.&amp;nbsp; The LMBD macro would appear sufficiently complex that a function may need to be used in lieu of a macro.&amp;nbsp; Of course this will be somewhat slower than the assembly code macro, as will most code written in C.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would appear that the LMBD macro takes the form it does so that the same number of execution cycles are required, independent of the return value.&amp;nbsp; This may have to be foregone, as the C compiler will likely generate different assembly code than the macro.&amp;nbsp; The equivalent C function would probably have the following form -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;byte LMBD( byte val){  if (val &amp;gt;= 0x10) {    if (val &amp;gt;= 0x40) {      if (val &amp;gt;= 0x80)  return 7;      else              return 6;    }    else {      if (val &amp;gt;= 0x20)  return 5;      else              return 4;    }  }  else {    if (val &amp;gt;= 0x04) {      if (val &amp;gt;= 0x08)  return 3;      else              return 2;    }    else {      if (val &amp;gt;= 0x02)  return 1;      else              return 0;    }  }}&lt;/PRE&gt;&lt;P&gt;If you can tolerate significant variation in the execution cycles, depending on the output value, the following inline assembly code should produce a similar output&amp;nbsp;to the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;byte LMBD( byte val){  __asm {        LDA  val;        LDX  #8;LOOP1:  DECX;        LSLA;        BCC  LOOP1;        STX  val;  }  return val;}&lt;/PRE&gt;&lt;P&gt;After cursory examination, it would appear that the equivalent of INT_OBJ should be setup as a C structure for each interrupt source.&amp;nbsp; INT_objtab would then become an array of structures.&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 May 2010 23:55:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/AN3496/m-p/202482#M16640</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2010-05-20T23:55:19Z</dc:date>
    </item>
  </channel>
</rss>

