<?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: Defining variables in assembler</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1277801#M17864</link>
    <description>&lt;P&gt;Hi Stano,&lt;/P&gt;&lt;P&gt;Thanks for your suggestions but it really didn't help me, probably because I don't think I posed my question correctly.&lt;/P&gt;&lt;P&gt;I composed another small test program:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ORG RAMStart&lt;BR /&gt;; Insert here your data definition.&lt;BR /&gt;multiplicand&amp;nbsp; &amp;nbsp;DS.W 1 ; Memory location $2000:$2001&lt;BR /&gt;multiplier&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DS.W 1 ; Memory location $2002:$2003&lt;BR /&gt;product&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DS.W 2 ; Memory location $2004:$2005:$2006:$2007&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;; code section&lt;BR /&gt;ORG ROMStart&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Entry:&lt;BR /&gt;_Startup:&lt;BR /&gt;LDS #RAMEnd+1 ; initialize the stack pointer&lt;/P&gt;&lt;P&gt;CLI ; enable interrupts&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;; Test Code&lt;BR /&gt;MOVW #$FFFF,multiplicand&amp;nbsp; &amp;nbsp; ; Decimal 65535 -&amp;gt; "multiplicand"($2000:$2001)&lt;BR /&gt;MOVW #$FFFF,multiplier&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;; Decimal 65535 -&amp;gt; "multiplier" ($2002:$2003)&lt;/P&gt;&lt;P&gt;LDD multiplicand&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;; "multiplicand" -&amp;gt; Accu D&lt;BR /&gt;LDY multiplier&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ; "multiplier" -&amp;gt; Accu Y&lt;BR /&gt;EMUL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ; (D) x (Y) -&amp;gt; Y:D&lt;BR /&gt;STY product&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ; Result high word -&amp;gt; "product"($2004:$2005) ; should be #$FFFE&lt;BR /&gt;STD product+2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ; Result low word -&amp;gt; "product+2"($2006:$2007)&amp;nbsp; ; should be #$0001&lt;/P&gt;&lt;P&gt;When I use the debugger and step through the program everything works as it should. The registers have the correct values and the memory locations have the correct values. My problem is with the "Data" window.&lt;/P&gt;&lt;P&gt;In that window it shows:&lt;/P&gt;&lt;P&gt;multiplicand&amp;nbsp; -1&amp;nbsp; int&lt;/P&gt;&lt;P&gt;multiplier&amp;nbsp; &amp;nbsp; &amp;nbsp; -1&amp;nbsp; int&lt;/P&gt;&lt;P&gt;product&amp;nbsp; &amp;nbsp;&amp;lt;4&amp;gt;&amp;nbsp; array&amp;nbsp; [2]&amp;nbsp; of int&lt;/P&gt;&lt;P&gt;var00001&amp;nbsp; &amp;nbsp;16384&amp;nbsp; int&lt;/P&gt;&lt;P&gt;It looks to me that in the Data window it is displaying the variables as signed words. How can I change that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 17 May 2021 23:16:56 GMT</pubDate>
    <dc:creator>roberthiebert</dc:creator>
    <dc:date>2021-05-17T23:16:56Z</dc:date>
    <item>
      <title>Defining variables in assembler</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1277193#M17861</link>
      <description>&lt;P&gt;MC9S12XEP100, CW 5.9.0 SE. I'm just starting out trying to create a simple test program in absolute assembler and I can't seem to define my variables correctly. For example&lt;/P&gt;&lt;P&gt;&amp;nbsp; varbyte&amp;nbsp; &amp;nbsp;DS.B 1&amp;nbsp; Works just fine with values from 0 to 255&lt;/P&gt;&lt;P&gt;&amp;nbsp; Varword&amp;nbsp; DS.W 1 behaves like a signed variable and will only allow values from 0 to 32767 before going negative. What am I doing wrong?&lt;/P&gt;&lt;P&gt;Robert&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 May 2021 21:02:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1277193#M17861</guid>
      <dc:creator>roberthiebert</dc:creator>
      <dc:date>2021-05-15T21:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Defining variables in assembler</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1277465#M17862</link>
      <description>&lt;P&gt;Hello Robert,&lt;/P&gt;
&lt;P&gt;Your definition is right. But in asm code you need to take care to use the right instructions and take care about flags also. It’s up to you if the “negative” flag (“N” and “C” in CCR) is accepted or not in the code. It depends on variable usage – as signed or as unsigned.&lt;/P&gt;
&lt;P&gt;If such variables are defined as signed or unsigned in C language, it is the compiler responsibility to translate is right into asm code. It depends on the variable definition in C code.&lt;/P&gt;
&lt;P&gt;You can read more on web about this topic also:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/18984515/x86-asm-assembler-difference-between-signed-and-unsigned-and-8-and-16-variab" target="_blank"&gt;https://stackoverflow.com/questions/18984515/x86-asm-assembler-difference-between-signed-and-unsigned-and-8-and-16-variab&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/19596729/signed-and-unsigned-convention-in-assembly-language" target="_blank"&gt;https://stackoverflow.com/questions/19596729/signed-and-unsigned-convention-in-assembly-language&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/11205522/identifying-signed-and-unsigned-values-in-assembly/11207281" target="_blank"&gt;https://stackoverflow.com/questions/11205522/identifying-signed-and-unsigned-values-in-assembly/11207281&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I think it could help you to solve your issue.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Stano.&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 07:57:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1277465#M17862</guid>
      <dc:creator>StanoA</dc:creator>
      <dc:date>2021-05-17T07:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Defining variables in assembler</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1277801#M17864</link>
      <description>&lt;P&gt;Hi Stano,&lt;/P&gt;&lt;P&gt;Thanks for your suggestions but it really didn't help me, probably because I don't think I posed my question correctly.&lt;/P&gt;&lt;P&gt;I composed another small test program:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ORG RAMStart&lt;BR /&gt;; Insert here your data definition.&lt;BR /&gt;multiplicand&amp;nbsp; &amp;nbsp;DS.W 1 ; Memory location $2000:$2001&lt;BR /&gt;multiplier&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DS.W 1 ; Memory location $2002:$2003&lt;BR /&gt;product&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DS.W 2 ; Memory location $2004:$2005:$2006:$2007&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;; code section&lt;BR /&gt;ORG ROMStart&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Entry:&lt;BR /&gt;_Startup:&lt;BR /&gt;LDS #RAMEnd+1 ; initialize the stack pointer&lt;/P&gt;&lt;P&gt;CLI ; enable interrupts&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;; Test Code&lt;BR /&gt;MOVW #$FFFF,multiplicand&amp;nbsp; &amp;nbsp; ; Decimal 65535 -&amp;gt; "multiplicand"($2000:$2001)&lt;BR /&gt;MOVW #$FFFF,multiplier&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;; Decimal 65535 -&amp;gt; "multiplier" ($2002:$2003)&lt;/P&gt;&lt;P&gt;LDD multiplicand&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;; "multiplicand" -&amp;gt; Accu D&lt;BR /&gt;LDY multiplier&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ; "multiplier" -&amp;gt; Accu Y&lt;BR /&gt;EMUL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ; (D) x (Y) -&amp;gt; Y:D&lt;BR /&gt;STY product&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ; Result high word -&amp;gt; "product"($2004:$2005) ; should be #$FFFE&lt;BR /&gt;STD product+2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ; Result low word -&amp;gt; "product+2"($2006:$2007)&amp;nbsp; ; should be #$0001&lt;/P&gt;&lt;P&gt;When I use the debugger and step through the program everything works as it should. The registers have the correct values and the memory locations have the correct values. My problem is with the "Data" window.&lt;/P&gt;&lt;P&gt;In that window it shows:&lt;/P&gt;&lt;P&gt;multiplicand&amp;nbsp; -1&amp;nbsp; int&lt;/P&gt;&lt;P&gt;multiplier&amp;nbsp; &amp;nbsp; &amp;nbsp; -1&amp;nbsp; int&lt;/P&gt;&lt;P&gt;product&amp;nbsp; &amp;nbsp;&amp;lt;4&amp;gt;&amp;nbsp; array&amp;nbsp; [2]&amp;nbsp; of int&lt;/P&gt;&lt;P&gt;var00001&amp;nbsp; &amp;nbsp;16384&amp;nbsp; int&lt;/P&gt;&lt;P&gt;It looks to me that in the Data window it is displaying the variables as signed words. How can I change that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 23:16:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1277801#M17864</guid>
      <dc:creator>roberthiebert</dc:creator>
      <dc:date>2021-05-17T23:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Defining variables in assembler</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1281871#M17867</link>
      <description>&lt;P&gt;Hi Robert,&lt;/P&gt;
&lt;P&gt;OK, just go to Data window, select such variable (e.g. multiplier – will be in blue row) , then right click, -&amp;gt; Format -&amp;gt; Selected/All -&amp;gt; and select format in which you want to see the variables.&lt;/P&gt;
&lt;P&gt;I hope it helps you.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Stano.&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 13:30:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1281871#M17867</guid>
      <dc:creator>StanoA</dc:creator>
      <dc:date>2021-05-25T13:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Defining variables in assembler</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1281938#M17868</link>
      <description>&lt;P&gt;Hi Stano,&lt;/P&gt;&lt;P&gt;Thanks for your reply, but changing the displayed format really isn't my problem. The problem is that the Data window displays my word variables as signed variables but I want them to be unsigned. I just don't know how I can communicate this to CodeWarrior.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 15:17:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1281938#M17868</guid>
      <dc:creator>roberthiebert</dc:creator>
      <dc:date>2021-05-25T15:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Defining variables in assembler</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1282304#M17870</link>
      <description>&lt;P&gt;Hi Robert,&lt;/P&gt;
&lt;P&gt;There is no possibility to define “signed” or “unsigned” variables in assembler. It is up to user to take care to use right functions for the required operation and also consider the possibility to receive negative result of that operation (flags N &amp;amp; C).&lt;/P&gt;
&lt;P&gt;It is possible select “HEX” format to view variables also and take care about highest bit meanings. There is also option uDec – I suppose “unsigned decimal” but it shows the same as DEC. I think it is due to show the right results not without sign – it would lead to mistakes.&lt;/P&gt;
&lt;P&gt;I hope it helps you.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Stano.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 06:36:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1282304#M17870</guid>
      <dc:creator>StanoA</dc:creator>
      <dc:date>2021-05-26T06:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Defining variables in assembler</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1282660#M17871</link>
      <description>&lt;P&gt;Hi Stano,&lt;/P&gt;&lt;P&gt;That did it! I didn't know what uDec meant so I never tried to change the format to that. If I had tried HEX I would have seen that the results were correct. So, what I learned from this is that DEC assumes a signed integer, uDec assumes an unsigned integer and HEX is just hex, and always correct. Thanks so much for being patient with me.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 15:17:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Defining-variables-in-assembler/m-p/1282660#M17871</guid>
      <dc:creator>roberthiebert</dc:creator>
      <dc:date>2021-05-26T15:17:35Z</dc:date>
    </item>
  </channel>
</rss>

