<?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: 16 bit compare routine in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/16-bit-compare-routine/m-p/255594#M19899</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The LDHX, CPHX solution is good only for 16-bit, and assumes 9S08 if SP-indexed, and certainly it can not be used with X-indexed operands.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More generic 16-bit (or higher) compares can be done for any addressing mode by using the Accumulator (A) in a series of LDA/CMP/BNE instructions, (the final BNE being redundant), starting from the MSB, like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;op1&amp;nbsp; rmb 2&lt;/P&gt;&lt;P&gt;op2 rmb 2&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp; lda op1&lt;/P&gt;&lt;P&gt;&amp;nbsp; cmp op2&lt;/P&gt;&lt;P&gt;&amp;nbsp; bne Skip&lt;/P&gt;&lt;P&gt;&amp;nbsp; lda op1+1&lt;/P&gt;&lt;P&gt;cmp op2+1&lt;/P&gt;&lt;P&gt;;;;;; bne Skip&lt;/P&gt;&lt;P&gt;Skip&lt;/P&gt;&lt;P&gt;; here we can use all comparison branches available, just like after a single CMP instruction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This method can be turned into a generic macro or subroutine that compares any two 16-bit (or higher) operands regardless of addressing mode.&amp;nbsp; (Care has to be taken when the macro is allowed to compare against immediate mode values to use the related syntax for those cases.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Many such macros are available for ASM8 &lt;A href="http://www.aspisys.com/code/hc08/common.html"&gt;here&lt;/A&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Sep 2013 10:12:48 GMT</pubDate>
    <dc:creator>tonyp</dc:creator>
    <dc:date>2013-09-30T10:12:48Z</dc:date>
    <item>
      <title>16 bit compare routine</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/16-bit-compare-routine/m-p/255592#M19897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have looked but could not find any assembly code for a 16 bit compare routine. We are using a QG4 part and I need to determine if a 16 bit value is =, &amp;lt;,or &amp;gt;.&lt;/P&gt;&lt;P&gt;there is an 8 bit routine but not sure if can be modified for 16 bits.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Sep 2013 19:37:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/16-bit-compare-routine/m-p/255592#M19897</guid>
      <dc:creator>paul_1951</dc:creator>
      <dc:date>2013-09-29T19:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: 16 bit compare routine</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/16-bit-compare-routine/m-p/255593#M19898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;H:X is a 16-bit register.&amp;nbsp; Try using the instructions LDHX and CPHX.&lt;/P&gt;&lt;P&gt;&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>Mon, 30 Sep 2013 07:59:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/16-bit-compare-routine/m-p/255593#M19898</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-09-30T07:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: 16 bit compare routine</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/16-bit-compare-routine/m-p/255594#M19899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The LDHX, CPHX solution is good only for 16-bit, and assumes 9S08 if SP-indexed, and certainly it can not be used with X-indexed operands.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More generic 16-bit (or higher) compares can be done for any addressing mode by using the Accumulator (A) in a series of LDA/CMP/BNE instructions, (the final BNE being redundant), starting from the MSB, like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;op1&amp;nbsp; rmb 2&lt;/P&gt;&lt;P&gt;op2 rmb 2&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp; lda op1&lt;/P&gt;&lt;P&gt;&amp;nbsp; cmp op2&lt;/P&gt;&lt;P&gt;&amp;nbsp; bne Skip&lt;/P&gt;&lt;P&gt;&amp;nbsp; lda op1+1&lt;/P&gt;&lt;P&gt;cmp op2+1&lt;/P&gt;&lt;P&gt;;;;;; bne Skip&lt;/P&gt;&lt;P&gt;Skip&lt;/P&gt;&lt;P&gt;; here we can use all comparison branches available, just like after a single CMP instruction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This method can be turned into a generic macro or subroutine that compares any two 16-bit (or higher) operands regardless of addressing mode.&amp;nbsp; (Care has to be taken when the macro is allowed to compare against immediate mode values to use the related syntax for those cases.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Many such macros are available for ASM8 &lt;A href="http://www.aspisys.com/code/hc08/common.html"&gt;here&lt;/A&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Sep 2013 10:12:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/16-bit-compare-routine/m-p/255594#M19899</guid>
      <dc:creator>tonyp</dc:creator>
      <dc:date>2013-09-30T10:12:48Z</dc:date>
    </item>
  </channel>
</rss>

