<?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>#DEFINE and EXTRN NUMBER are incompatible ???</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/16896/define-and-extrn-number-are-incompatible</link><description> Dear friends, 
 
Plz help me in solving this bad problem: 
 
PROBLEM DESCRIPTION: 
 
I have a number defined in C and I DONT want to alocate memory in 8051 for this number : 
 
	#define myNumber 0x1234 
 
All is well, when i work with myNumber in C for</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: #DEFINE and EXTRN NUMBER are incompatible ???</title><link>https://community.arm.com/thread/122197?ContentTypeID=1</link><pubDate>Sat, 22 Nov 2003 08:33:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4d33e63f-478f-4a5f-aa8e-a9c33ef6df1f</guid><dc:creator>marcu andy</dc:creator><description>&lt;p&gt;You are right Andy Neil,&lt;br /&gt;
Thanks again!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #DEFINE and EXTRN NUMBER are incompatible ???</title><link>https://community.arm.com/thread/110625?ContentTypeID=1</link><pubDate>Sat, 22 Nov 2003 05:32:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:95c98c90-5bc1-47af-879f-a71ecd6f694c</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;the C51 manual ... Chapter 4 lacks in information on haw preprocessor works.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
That&amp;#39;s because it&amp;#39;s a Compiler &lt;b&gt;Manual&lt;/b&gt; - not a &amp;#39;C&amp;#39; textbook!&lt;br /&gt;
&lt;br /&gt;
It is not the job of a Compiler &lt;b&gt;Manual&lt;/b&gt; to tech you how to write programs in &amp;#39;C&amp;#39; - that is the job of a textbook and, preferably, a &amp;#39;C&amp;#39; programming class.&lt;br /&gt;
&lt;br /&gt;
See the &lt;b&gt;Preface&lt;/b&gt; in the front of the printed C51 &lt;b&gt;Manual&lt;/b&gt; (same as the PDF version):&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;This manual describes how to use the Cx51 Optimizing C Compilers to compile C programs for your target 8051 environment ... This manual assumes that you are familiar with the Windows operating system, know how to program 8051 processors, &lt;b&gt;and have a working knowledge of the C programming language&lt;/b&gt;.&amp;quot;&lt;/i&gt; (my emphasis)&lt;br /&gt;
&lt;br /&gt;
Also:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;If you have questions about programming in C, or if you would like more&lt;br /&gt;
information about the C programming language, refer to &amp;quot;Books About the C Language&amp;quot; on page 16.&amp;quot;&lt;/i&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #DEFINE and EXTRN NUMBER are incompatible ???</title><link>https://community.arm.com/thread/95940?ContentTypeID=1</link><pubDate>Fri, 21 Nov 2003 23:47:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4c385b00-9742-4671-8ae7-ee01f1bca21a</guid><dc:creator>marcu andy</dc:creator><description>&lt;p&gt;Thank you verry much,&lt;br /&gt;
Hans-Bernhard Broeker and Andrew Neil&lt;br /&gt;
&lt;b&gt;My problem is SOLVED!!!!&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I found the search in forum more usefull then the C51 manual because Chapter 4 lacks in information on haw preprocessor works.&lt;br /&gt;
&lt;br /&gt;
The corected code follows:&lt;br /&gt;
&lt;pre&gt;
//file main.c-------------
/*************************
Hans-Bernhard Broeker and
Andrew Neil
solution
**************************/

//myNuber must be seen both by ASM and C
//so is defined in a comon include file
#include &amp;lt;comon.h&amp;gt;

//function defined in ASM which use myNumber
extern  unsigned char GetHiByte(void);

//reserve memory location
unsigned char HiByte;

void main (void)
{
	HiByte=myNumber/256;
	HiByte=GetHiByte();
}



//file comon.h-------------

#ifndef _COMON_H_
#define _COMON_H_

//I wish to see this number both in ASM and C
//PLZ NOTE: I dont want to reserve memory for myNumber
//i only wish to use it&amp;#39;s High Byte in a data memory location

#define myNumber 0x1234

#endif


;file func.a51--------------

;myNuber must be seen both by ASM and C
;so is defined in a comon include file
$include (comon.h)

?PR?GetHiByte?FUNC? segment code

	public GetHiByte

rseg ?PR?GetHiByte?FUNC?

	using 0
GetHiByte:

	mov r7,#HIGH(myNumber)	; Perfectly now!!
			 	;translated as
				;MOV  R7,#012H
	ret

end
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #DEFINE and EXTRN NUMBER are incompatible ???</title><link>https://community.arm.com/thread/86578?ContentTypeID=1</link><pubDate>Fri, 21 Nov 2003 12:09:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4e493447-74ce-4de4-8405-7a92af86a2b9</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Your problem is that you don&amp;#39;t understand how #define actually works.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
To gain such understanding, read-up on the &lt;b&gt;preprocessor&lt;/b&gt; in your &amp;#39;C&amp;#39; textbook.&lt;br /&gt;
&lt;br /&gt;
You could also try a &amp;#39;&lt;b&gt;Search&lt;/b&gt;&amp;#39; on this forum for &amp;quot;preprocessor&amp;quot; (or maybe &amp;quot;pre-processor&amp;quot;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: #DEFINE and EXTRN NUMBER are incompatible ???</title><link>https://community.arm.com/thread/50206?ContentTypeID=1</link><pubDate>Fri, 21 Nov 2003 10:09:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c64993a3-973a-4477-90e8-61f9e4fd80b6</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;Your problem is that you don&amp;#39;t understand how #define actually works.  You should put that #define into a separate file, and #include that both in the C and in the assembler source file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>