<?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のトピック9S08QE128 Note: INC PPAGE does not set the Z flag when wrapping around from 7 to 0</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182128#M13357</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN style="font-family: 'Comic Sans MS';"&gt;I spent about an hour chasing this little gotcha inside a quite large application, so I thought it might be of interest to some of you.&lt;BR /&gt;&lt;BR /&gt;When PPAGE is 7 (last possible ppage) for 9S08QE128, doing INC PPAGE will make PPAGE zero but the Z flag will not be set.&lt;BR /&gt;&lt;BR /&gt;This seemingly wrong result is actually correct in that the MCU internally is incrementing the 7 and getting a non-zero value.&amp;nbsp; But, when the value is written back to PPAGE only bits 2..0 are affected (doing an implicit AND #7 operation) and the debugger will show you that PPAGE is zero right after the INC instruction executes, but the Z flag will be clear.&amp;nbsp; So, this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;LDA PPAGE&lt;BR /&gt;INCA&lt;BR /&gt;AND #7&lt;BR /&gt;BEQ DONE&lt;BR /&gt;STA PPAGE&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'Comic Sans MS';"&gt;works, but the the nicer&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&lt;BR /&gt;INC PPAGE&lt;BR /&gt;BEQ DONE&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'Comic Sans MS';"&gt;doesn't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="time_text"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by tonyp on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-08-27&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:12 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Aug 2008 04:11:05 GMT</pubDate>
    <dc:creator>tonyp</dc:creator>
    <dc:date>2008-08-27T04:11:05Z</dc:date>
    <item>
      <title>9S08QE128 Note: INC PPAGE does not set the Z flag when wrapping around from 7 to 0</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182128#M13357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN style="font-family: 'Comic Sans MS';"&gt;I spent about an hour chasing this little gotcha inside a quite large application, so I thought it might be of interest to some of you.&lt;BR /&gt;&lt;BR /&gt;When PPAGE is 7 (last possible ppage) for 9S08QE128, doing INC PPAGE will make PPAGE zero but the Z flag will not be set.&lt;BR /&gt;&lt;BR /&gt;This seemingly wrong result is actually correct in that the MCU internally is incrementing the 7 and getting a non-zero value.&amp;nbsp; But, when the value is written back to PPAGE only bits 2..0 are affected (doing an implicit AND #7 operation) and the debugger will show you that PPAGE is zero right after the INC instruction executes, but the Z flag will be clear.&amp;nbsp; So, this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;LDA PPAGE&lt;BR /&gt;INCA&lt;BR /&gt;AND #7&lt;BR /&gt;BEQ DONE&lt;BR /&gt;STA PPAGE&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'Comic Sans MS';"&gt;works, but the the nicer&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&lt;BR /&gt;INC PPAGE&lt;BR /&gt;BEQ DONE&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'Comic Sans MS';"&gt;doesn't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="time_text"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by tonyp on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-08-27&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:12 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2008 04:11:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182128#M13357</guid>
      <dc:creator>tonyp</dc:creator>
      <dc:date>2008-08-27T04:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: 9S08QE128 Note: INC PPAGE does not set the Z flag when wrapping around from 7 to 0</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182129#M13358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;That's normal. CPU does set Z flag immediately after evaluating the result of add-one operation. CPU doesn't reread PPAGE after INC PPAGE. CPU just reads PPAGE=7, increments it (7+1=8), updates status flags, writes 8 to PPAGE. Of course 8 &amp;lt;&amp;gt; 0.&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by kef on &lt;SPAN class="date_text"&gt;2008-08-27&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;09:04 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2008 13:01:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182129#M13358</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2008-08-27T13:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: 9S08QE128 Note: INC PPAGE does not set the Z flag when wrapping around from 7 to 0</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182130#M13359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;There is also a big difference in the logic flow.&lt;BR /&gt;In the second&amp;nbsp; case, PPAGE gets incremented regardless.&lt;BR /&gt;In the first case if you take the branch, you will not save it back to PPAGE.&lt;BR /&gt;Thanks for the tip....&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2008 19:53:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182130#M13359</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-08-27T19:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: 9S08QE128 Note: INC PPAGE does not set the Z flag when wrapping around from 7 to 0</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182131#M13360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;JimDon wrote:&lt;BR /&gt;There is also a big difference in the logic flow.&lt;BR /&gt;In the second&amp;nbsp; case, PPAGE gets incremented regardless.&lt;BR /&gt;In the first case if you take the branch, you will not save it back to PPAGE.&lt;BR /&gt;Thanks for the tip....&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;FONT face="Comic Sans MS"&gt;That's correct, my code meant to check for the end loop condition when going from page 0 up through all the available pages, so it didn't matter.&amp;nbsp; But if you move the BEQ after STA PPAGE, you'll get the same logic flow.&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2008 20:31:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/9S08QE128-Note-INC-PPAGE-does-not-set-the-Z-flag-when-wrapping/m-p/182131#M13360</guid>
      <dc:creator>tonyp</dc:creator>
      <dc:date>2008-08-27T20:31:41Z</dc:date>
    </item>
  </channel>
</rss>

