<?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>S12 / MagniV MicrocontrollersのトピックRe: MC9S12GC32 Assembly Code Division</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192708#M7584</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something is not right here. 5113/5 should return 0x9999 for binary remainder, not 3. The meaning of 0x9999 is that 0x9999 / (2^16) gives&amp;nbsp;about 0.6.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To convert 0x9999 into 6 you should multiply 0x9999 by decimal 10 and divide by 2^16. 0x9999 * 10 = 0x5FFFA. In this case you will get 5, not 6. It's becouse of rounding. 0xFFFA&amp;nbsp;(0.9999) is very close to 2^16 (1.0). To round you can add 0x8000 (0.5) to product before dividing it by 0x10000.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Apr 2010 23:31:17 GMT</pubDate>
    <dc:creator>kef</dc:creator>
    <dc:date>2010-04-16T23:31:17Z</dc:date>
    <item>
      <title>MC9S12GC32 Assembly Code Division</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192707#M7583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working on an assembly&amp;nbsp;project where I need to do division and make use of the remainder when the remainder is less than 1.&amp;nbsp; For example 5113/5 which "on paper" equal 1022.6.&amp;nbsp; However the result of this division inside the micro&amp;nbsp;is Y=3FE (1022) and D=3 (which represents .6)&amp;nbsp; I'm aware that the fractional portion of a quotient is stored as a binary weighted value but I' trying to understand how I can manipulate the 3, in this case, in such a way that it gets stored as an integer 6 so that I can ultimately effectively multiply the result of 1022.6 by 10 to get 10226.&amp;nbsp; Anyone have any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;uCRFun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Apr 2010 22:59:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192707#M7583</guid>
      <dc:creator>uCRFun</dc:creator>
      <dc:date>2010-04-16T22:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12GC32 Assembly Code Division</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192708#M7584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something is not right here. 5113/5 should return 0x9999 for binary remainder, not 3. The meaning of 0x9999 is that 0x9999 / (2^16) gives&amp;nbsp;about 0.6.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To convert 0x9999 into 6 you should multiply 0x9999 by decimal 10 and divide by 2^16. 0x9999 * 10 = 0x5FFFA. In this case you will get 5, not 6. It's becouse of rounding. 0xFFFA&amp;nbsp;(0.9999) is very close to 2^16 (1.0). To round you can add 0x8000 (0.5) to product before dividing it by 0x10000.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Apr 2010 23:31:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192708#M7584</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-04-16T23:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12GC32 Assembly Code Division</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192709#M7585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response KEF.&amp;nbsp; Prior to posting this I had submitted a service request with Freescale (I needed a solution as quickly as possible) and before I could respond to your response someone from tech support contacted me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't quite follow all of what you've suggested in terms of the remainder being 0x9999 not 3 because 3 is what I see in the D register when I step through that code segment.&amp;nbsp; I'm not doubting what you say, I just don't follow completely.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the other hand, tech support indicated that 3 is what should be in the D register and to convert that result to an integer I can work with I could multiply it by 10 and the divide it by 5.&amp;nbsp; The end result of doing that is 6. Yeah!!&amp;nbsp; It's easy enough now to multiply the original quotient by 10 and add 6 to get 10226&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>Sat, 17 Apr 2010 01:15:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192709#M7585</guid>
      <dc:creator>uCRFun</dc:creator>
      <dc:date>2010-04-17T01:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12GC32 Assembly Code Division</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192710#M7586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I mixed remainder with fractional part few times. I see why you have 3 now :smileyhappy:.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you do integer division 5113/5 and get 3FE and remainder 3. Fractional part, 0.6 is 3/5.&amp;nbsp;You should do one more division to get that fractional part.&amp;nbsp;Binary weighted fraction&amp;nbsp;in this case is &amp;nbsp;3&amp;nbsp;* 0x10000 /&amp;nbsp;5. It's&amp;nbsp;0x9999 I mentioned before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It was not clear why were you talking about weighted fraction. Of course you&amp;nbsp;can simply rearrange order of operations, multiply by 10 then divide instead of divide then multiply by 10.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Apr 2010 01:54:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12GC32-Assembly-Code-Division/m-p/192710#M7586</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-04-17T01:54:24Z</dc:date>
    </item>
  </channel>
</rss>

