<?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 Calculating an Average in HCS08 Assembly in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Calculating-an-Average-in-HCS08-Assembly/m-p/190205#M6833</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering the simplest and best way is to calculate an average of 3 8-bit numbers using HCS08 Assembly code.&amp;nbsp; I'm getting stuck on what happens when adding the first two numbers results in an overflow and how to proceed on getting the final sum before dividing by 3 (which I was planning on doing using the DIV instruction, but that depends on your suggestions).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RTS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Apr 2010 02:39:20 GMT</pubDate>
    <dc:creator>rsheldon</dc:creator>
    <dc:date>2010-04-09T02:39:20Z</dc:date>
    <item>
      <title>Calculating an Average in HCS08 Assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Calculating-an-Average-in-HCS08-Assembly/m-p/190205#M6833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering the simplest and best way is to calculate an average of 3 8-bit numbers using HCS08 Assembly code.&amp;nbsp; I'm getting stuck on what happens when adding the first two numbers results in an overflow and how to proceed on getting the final sum before dividing by 3 (which I was planning on doing using the DIV instruction, but that depends on your suggestions).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RTS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Apr 2010 02:39:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Calculating-an-Average-in-HCS08-Assembly/m-p/190205#M6833</guid>
      <dc:creator>rsheldon</dc:creator>
      <dc:date>2010-04-09T02:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an Average in HCS08 Assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Calculating-an-Average-in-HCS08-Assembly/m-p/190206#M6834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello rsheldon,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is one way to find the average of 3 8-bit numbers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  CLRA  PSHA   ;zero a place on the stack for high byte of addition result  LDA value1  ADD value2         ;add first two values  BCC XXX1  INC 1,SP  ;store possible rolloverXXX1  ADD value3   ;add third value  BCC XXX2  INC 1,SP  ;add possible rollover to high byteXXX2  PULH   ;low byte of result already in A, put high byte in H  LDX #3  ;set divisor  DIV   ;do the division     ;the result is in A with any remainder in H&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:41:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Calculating-an-Average-in-HCS08-Assembly/m-p/190206#M6834</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2020-10-29T09:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating an Average in HCS08 Assembly</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Calculating-an-Average-in-HCS08-Assembly/m-p/190207#M6835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! This works perfectly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Apr 2010 03:36:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Calculating-an-Average-in-HCS08-Assembly/m-p/190207#M6835</guid>
      <dc:creator>rsheldon</dc:creator>
      <dc:date>2010-04-10T03:36:50Z</dc:date>
    </item>
  </channel>
</rss>

