<?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 Re: HCS08C: Small Memory Model and _near pointer qualifier for optimization in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151188#M3618</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;no, there are cases like this one, extended loading and only dereferenciation where they are a bit shorter (but not faster in this case, BTW). Most of the time, and especially when you manipulate them (increment, compute, pass around, ...) far pointers are less efficient.&lt;BR /&gt;&lt;BR /&gt;For plain dereferenciation however it does not matter much.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;(and, BTW, __far pointers also occupy twice as much RAM)&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Apr 2008 12:35:49 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2008-04-29T12:35:49Z</dc:date>
    <item>
      <title>HCS08C: Small Memory Model and _near pointer qualifier for optimization</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151182#M3612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm using small memory model for my LC60 application. All my pointers have two bytes.&lt;/DIV&gt;&lt;DIV&gt;When should I use __near qualifier to pointer types for more efficient code generation?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;10x&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by BasePointer on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-04-28&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;06:18 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 22:18:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151182#M3612</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2008-04-28T22:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08C: Small Memory Model and _near pointer qualifier for optimization</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151183#M3613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi BP,&lt;BR /&gt;&lt;BR /&gt;You should use the __near qualifier only when your variable is located in the direct page area (as this is the only area that can be accessed using DIR addressing mode and thus 1-byte address).&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2008 23:15:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151183#M3613</guid>
      <dc:creator>fabio</dc:creator>
      <dc:date>2008-04-28T23:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08C: Small Memory Model and _near pointer qualifier for optimization</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151184#M3614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If I declare an array (for example "char foo[30];" ) in direct page area, will the compiler automatically use __near pointer when&amp;nbsp;it reachs them?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;10x,&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 01:39:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151184#M3614</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2008-04-29T01:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08C: Small Memory Model and _near pointer qualifier for optimization</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151185#M3615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;No,&lt;BR /&gt;&lt;BR /&gt;As far as I know, you must use the __near modifier to instruct the compiler to use DIR addressing mode.&lt;BR /&gt;&lt;BR /&gt;You can create a simple application and use the simulator to see the results your own.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by fabio on &lt;SPAN class="date_text"&gt;2008-04-28&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;04:00 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 01:59:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151185#M3615</guid>
      <dc:creator>fabio</dc:creator>
      <dc:date>2008-04-29T01:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08C: Small Memory Model and _near pointer qualifier for optimization</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151186#M3616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Yes and no, it depends on which kind of pointer we talk about.&lt;BR /&gt;The compiler does not touch user defined pointers, if you define a pointer into the array, the compiler will use a __near pointer only if that pointer is defined as __near pointer.&lt;BR /&gt;On the yes side, pointers defined by just using the array, for example with the address (&amp;amp;) operator, or with [] are automatically near pointers.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;Below some test code&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#pragma push#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGEchar foo[30];#pragma popchar * ptr_far = foo; // not a near pointerchar *__near ptr_near = foo; // explicit near pointerchar i = 0;void f0(void) {  *ptr_far = 1;}void f1(void) {  *ptr_near = 2;}void f2(void) {  foo[i] = 3; // automatically uses __near.}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;generates:&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;    4:  #pragma push    5:  #pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE    6:  char foo[30];    7:  #pragma pop    8:  char * ptr_far = foo; // not a near pointer    9:  char *__near ptr_near = foo; // explicit near pointer   10:     11:  char i = 0;   12:  void f0(void) {Function: f0Options : -Cs08  -Ms   13:    *ptr_far = 1;  0000 a601     [2]             LDA   #1  0002 320000   [5]             LDHX  ptr_far  0005 f7       [2]             STA   ,X   14:  }  0006 81       [6]             RTS      15:  void f1(void) {Function: f1Options : -Cs08  -Ms   16:    *ptr_near = 2;  0000 a602     [2]             LDA   #2  0002 ce0000   [4]             LDX   ptr_near  0005 8c       [1]             CLRH    0006 f7       [2]             STA   ,X   17:  }  0007 81       [6]             RTS      18:  void f2(void) {Function: f2Options : -Cs08  -Ms   19:    foo[i] = 3; // automatically uses __near.  0000 ce0000   [4]             LDX   i  0003 8c       [1]             CLRH    0004 a603     [2]             LDA   #3  0006 e700     [3]             STA   @foo,X   20:  }  0008 81       [6]             RTS  &lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:54:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151186#M3616</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2020-10-29T08:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08C: Small Memory Model and _near pointer qualifier for optimization</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151187#M3617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Guru,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;As I saw, function f0() consumes 7 bytes (far pointer). But f1(near pointer) consumes 8 bytes. Are far pointers more efficient?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;10x,&lt;/DIV&gt;&lt;DIV&gt;BP.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 12:21:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151187#M3617</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2008-04-29T12:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08C: Small Memory Model and _near pointer qualifier for optimization</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151188#M3618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;no, there are cases like this one, extended loading and only dereferenciation where they are a bit shorter (but not faster in this case, BTW). Most of the time, and especially when you manipulate them (increment, compute, pass around, ...) far pointers are less efficient.&lt;BR /&gt;&lt;BR /&gt;For plain dereferenciation however it does not matter much.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;(and, BTW, __far pointers also occupy twice as much RAM)&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2008 12:35:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HCS08C-Small-Memory-Model-and-near-pointer-qualifier-for/m-p/151188#M3618</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-04-29T12:35:49Z</dc:date>
    </item>
  </channel>
</rss>

