<?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>CodeWarrior for MCUのトピックRe: Confusing CW manual</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138007#M2134</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Daniel,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Thank you for your response.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;So the "real" issue is the mixing of signed and unsigned types in a single expression, without proper precautions.&amp;nbsp; Perhaps the manual should have been more explicit.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;When using unsigned types, I tend to use the macro substitutions of &lt;FONT face="Courier New"&gt;byte&lt;/FONT&gt;, &lt;FONT face="Courier New"&gt;word&lt;/FONT&gt; and &lt;FONT face="Courier New"&gt;dword&lt;/FONT&gt;.&amp;nbsp; As well as fewer characters to enter, their use tends to make the unsigned types more obviously different than the signed types, for me.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Do you know of an alternative reference document for CW inline assembler?&amp;nbsp; Am I correct in assuming that this is compiler dependent, and outside the scope of ANSI C?&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Nov 2006 12:41:35 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2006-11-27T12:41:35Z</dc:date>
    <item>
      <title>HC08: Confusing CW manual</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138005#M2132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Hello all,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;I have recently been reading (perhaps belatedly) the Compiler manual for CW08 V5.0.&amp;nbsp; I have come across a couple of areas I am not particularly happy with, and find somewhat confusing.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;The following paragraph can be found within section 9, "Generating Compact Code" -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE class="jive-quote" dir="ltr"&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;&lt;STRONG&gt;Unsigned Data Types&lt;/STRONG&gt;&lt;BR /&gt;Using unsigned data types is acceptable as signed operations are much more complex than unsigned ones (e.g., shifts, divisions and bitfield operations). But it is a bad idea to use unsigned types just because a value is always larger or equal to zero, and because the type can hold a larger positive number.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;The author does not say why it is considered a "bad idea". I might have considered the use of unsigned data types a very good idea if it results in simpler and more compact code, and avoids the need to use an int variable in place of char, or a long in place of int.&amp;nbsp; &lt;SPAN style="color: #6633FF;"&gt;What could be the perceived problem with using unsigned data types?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;However, I am more generally unhappy with the whole of section 11, "High-Level Inline Assembler for the Freescale HC(S)08".&amp;nbsp; It is assumed the reader is already familiar with terms like "EBNF Syntax", and the information is given in a very cryptic fashion.&amp;nbsp; The code examples given are sparse, and do not really explain the features of inline assembler that differ from normal assembler (that I am&amp;nbsp;reasonably familiar with).&amp;nbsp; Within the code snippets, comments are virtually non-existent.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Additional addressing modes, not available in normal assembler, are not adequately explained.&amp;nbsp; I find the paragraph on "In &amp;amp; Gen Sets" very confusing.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;I get the feeling that a 10 page limit must have been placed on the inline assembler section - it is well below the standard of other manuals, such as the Assembler manual.&amp;nbsp; &lt;SPAN style="color: #6633FF;"&gt;Having said this, can anyone suggest additional information about inline assembler, perhaps in the form of a tutorial?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Regards,&lt;BR /&gt;Mac&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;Message Edited by CrasyCat on &lt;SPAN class="date_text"&gt;2007-04-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:44 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Nov 2006 22:40:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138005#M2132</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-11-26T22:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Confusing CW manual</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138006#M2133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Not sure what the point is about the not use of unsigned.&lt;BR /&gt;Maybe that using unsigned types also has its problems, for example:&lt;BR /&gt;&lt;PRE&gt;
unsigned int a; /* values 1..1000 */
int b; /* values -1000..+1000 */
  int less_a_b(void) {
  return a &amp;lt; b; /* unsigned compare! */
}
&lt;/PRE&gt;&lt;BR /&gt;Basically mixing signed and unsigend may cause troubles, if you are not very familiar with the ANSI C standard.&lt;BR /&gt;Using "int a" in this (constructed) sample would cause the expected behavior of a singed compare.&lt;BR /&gt;&lt;BR /&gt;Anyway, I don't think that signed arithmetic is "much more complex", I would say it's a bit more expensive in some cases.&lt;BR /&gt;&lt;BR /&gt;I don't have the manual in front of me, but the "In &amp;amp; Gen Sets" are to tell the compiler which register are really needed (when this is not obvious given the instruction). For example, for an HLI RTS the compiler does assume that every register is returned. If the code does explicitly state that for the RTS, the H and X don't have to be preserved, then the compiler can use those registers for accessing the stack.&lt;BR /&gt;(instead of a ADD 1,SP -&amp;gt; TSX; ADD 0,X)&lt;BR /&gt;In other words, you don't have to specify those sets. If you do not, then the generated code may miss some optimization opportunities.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 02:57:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138006#M2133</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-11-27T02:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Confusing CW manual</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138007#M2134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Daniel,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Thank you for your response.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;So the "real" issue is the mixing of signed and unsigned types in a single expression, without proper precautions.&amp;nbsp; Perhaps the manual should have been more explicit.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;When using unsigned types, I tend to use the macro substitutions of &lt;FONT face="Courier New"&gt;byte&lt;/FONT&gt;, &lt;FONT face="Courier New"&gt;word&lt;/FONT&gt; and &lt;FONT face="Courier New"&gt;dword&lt;/FONT&gt;.&amp;nbsp; As well as fewer characters to enter, their use tends to make the unsigned types more obviously different than the signed types, for me.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Do you know of an alternative reference document for CW inline assembler?&amp;nbsp; Am I correct in assuming that this is compiler dependent, and outside the scope of ANSI C?&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 12:41:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138007#M2134</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-11-27T12:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Confusing CW manual</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138008#M2135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Well, about this unsigned manual statement, I don't know if this was the point the original author did intend to make. Maybe. It's just my note why blindly using unsigned, if values are never negative, does not work in all cases too.&lt;BR /&gt;About the manual, sorry, I don't have another manual for you.&lt;BR /&gt;Having a look at the runtime support (lib\hc08c\src\rtshc08.c) may also help a bit, at least this code does make use of the "In &amp;amp; Gen Sets".&lt;BR /&gt;&lt;BR /&gt;HLI is of course very processor and compiler specific. I think ANSI C defines the keyword asm and that it is implementation specific. And that's about it. Everything else is beyond ANSI C.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2006 21:59:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC08-Confusing-CW-manual/m-p/138008#M2135</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-11-27T21:59:43Z</dc:date>
    </item>
  </channel>
</rss>

