<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Invalid mspace</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/42339/invalid-mspace</link><description> Hello, 
 
I had this appear when I tried to compile my code in C. 
 WARNING C196: MSPACE PROBABLY INVALID 
 
I do know that this occurs when we try to convert a constant to a pointer constant and hence yielding an invalid memory space. An example char</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Invalid mspace</title><link>https://community.arm.com/thread/42113?ContentTypeID=1</link><pubDate>Tue, 27 Apr 2004 23:02:43 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a9227fbb-dd3d-4f8b-9bdd-a805dd45e5aa</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;The 8051 has many separate address spaces (code, data, xdata, idata, etc).  The C language expects there to be a single address space.  To cope, Keil C has different sorts of pointers.  An xdata* is not the same type as a code*.  &amp;quot;Generic&amp;quot; pointers, without an explicit compile-time type, are tagged with an extra byte to indicate which memory space they actually point into.&lt;br /&gt;
&lt;br /&gt;
All this makes it extremely dangerous to do the all-too-common sort of munging about with integers and casting them into pointers.  It&amp;#39;s not one flat address space, and the binary representation of pointers is not really a simple integer offset.  You have to know exactly what you&amp;#39;re doing, and exactly how the compiler represents and treats pointers.  Study the manual on this topic carefully.&lt;br /&gt;
&lt;br /&gt;
Take a look at the macros in absacc.h for a start.&lt;br /&gt;
&lt;br /&gt;
I&amp;#39;d suggest always declaring pointers with an explicit memory space type unless you really need the generic capability for some reason.  Memory model makes a difference.&lt;br /&gt;
&lt;br /&gt;
In this particular case, I expect the compiler is warning you because 0x464 is too big to point into data space (which is only 128 bytes long), yet the tag byte of that value (0) would mean that the pointer does point into data space.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;I was trying to store a pointer memptr into memory space 0x463&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
If it&amp;#39;s actually important for you to control the address at which memptr appears, you can use &lt;b&gt;_at_&lt;/b&gt; (as suggested), or put the variable into its own segment and use linker options.  If you just slam address 0x463, how do you know there&amp;#39;s nothing else there already?  But if you insist, you need a pointer to a pointer if you want to indirectly change where a pointer points.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Invalid mspace</title><link>https://community.arm.com/thread/42116?ContentTypeID=1</link><pubDate>Tue, 27 Apr 2004 22:39:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:65d8a6fa-c96b-42c7-86e0-067fa0df0885</guid><dc:creator>Li Li</dc:creator><description>&lt;p&gt;ASSEMBLY LISTING of your code above:&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
                                           ; SOURCE LINE # 1&lt;br /&gt;
0000 7B00              MOV     R3,#00H&lt;br /&gt;
0002 7A04              MOV     R2,#04H&lt;br /&gt;
0004 7963              MOV     R1,#063H&lt;br /&gt;
0006 8B00        R     MOV     memptr,R3&lt;br /&gt;
0008 8A00        R     MOV     memptr+01H,R2&lt;br /&gt;
000A 8900        R     MOV     memptr+02H,R1&lt;br /&gt;
&lt;br /&gt;
                                      ; SOURCE LINE # 2&lt;br /&gt;
000C 7B00              MOV     R3,#00H&lt;br /&gt;
000E 7A04              MOV     R2,#04H&lt;br /&gt;
0010 7964              MOV     R1,#064H&lt;br /&gt;
0012 8B00        R     MOV     memptr,R3&lt;br /&gt;
0014 8A00        R     MOV     memptr+01H,R2&lt;br /&gt;
0016 8900        R     MOV     memptr+02H,R1&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
 Is that you want?&lt;br /&gt;
______________________________________&lt;br /&gt;
&lt;b&gt; void * xdata memptr  _at_  0x463;&lt;br /&gt;
  memptr = 0x464;&lt;br /&gt;
&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>