<?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>How to use LOW or HIGH in A51?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/22073/how-to-use-low-or-high-in-a51</link><description> 
I am writing a 8051 assembly program and try to use LOW/HIGH. When
i ran the following 

 
MOV R1,#LOW (variable)
 

 
R1 = LSB address byte of the variable, not LSB byte of the
variable. How can I get it? 
 </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: How to use LOW or HIGH in A51?</title><link>https://community.arm.com/thread/99516?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2007 11:49:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a08ef445-0aa9-4a7a-99e1-a857d411ed71</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;&lt;p&gt;
The name of a variable is the address where the variable lives,
not the value at that address. LOW and HIGH return the LSB and MSB of
that 16-bit address. These expressions are not executable code and do
not themselves fetch data; they are just interpreted by the
assembler.&lt;/p&gt;

&lt;p&gt;
To move data from an address, you want to use the MOV instruction
in some form.&lt;/p&gt;

&lt;p&gt;
The # indicates &amp;quot;immediate addressing&amp;quot;, which is to say that the
address will be built into the instruction (as opposed to being in
another register or somewhere in data memory).&lt;/p&gt;

&lt;p&gt;
Assuming the 16-bit address means that your variable is located in
xdata, you probably want code that looks something like:&lt;/p&gt;

&lt;pre&gt;
    MOV DPTR, #variable
    MOVX A, @DPTR
    MOV R0, A
&lt;/pre&gt;

&lt;p&gt;
(Fair warning: I don&amp;#39;t do much in assembler and just typed that in
off the top of my head without trying it...)&lt;/p&gt;

&lt;p&gt;
If you really want to use LOW and HIGH, the code could look
like:&lt;/p&gt;

&lt;pre&gt;
    MOV DPL, #LOW(variable)
    MOV DPH, #HIGH(variable)
    MOVX A, @DPTR
    MOV R0, A
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
But this is a slightly less efficient way to load the DPTR if you
(the assembler) already knows the address. This form is more useful
for a pointer parameter passed in registers (for example), in which
case LOW and HIGH wouldn&amp;#39;t be used.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LOW or HIGH in A51?</title><link>https://community.arm.com/thread/48434?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2007 11:41:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cca197de-2c51-4040-9a8a-052fdfd8ac36</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;R1 = LSB address byte of the variable, not LSB byte of the
variable.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Asm programs don&amp;#39;t have variables the way C programs do; they have
symbols, which are just names for addresses or constant numbers. In
particular, asm &amp;quot;variables&amp;quot; are never larger than one byte, so they
don&amp;#39;t have an LSB to speak of.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LOW or HIGH in A51?</title><link>https://community.arm.com/thread/88463?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2007 09:07:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8cb40811-5df5-4de9-99c2-d483ceeb1c80</guid><dc:creator>Robert McNamara</dc:creator><description>&lt;p&gt;&lt;p&gt;
No, a quick look at the User Manaul says that will not work.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LOW or HIGH in A51?</title><link>https://community.arm.com/thread/48432?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2007 09:05:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4e9794f7-1b1f-4d90-a9f1-74fae25c9b5b</guid><dc:creator>Robert McNamara</dc:creator><description>&lt;p&gt;&lt;p&gt;
I don&amp;#39;t know the 8051, but if&lt;/p&gt;

&lt;pre&gt;
MOV  R1,#LOW   (variable)
&lt;/pre&gt;

&lt;p&gt;
puts the LSB address of variable in R1 then&lt;/p&gt;

&lt;pre&gt;
MOV R1,LOW (variable)
&lt;/pre&gt;

&lt;p&gt;
should put the value at LSB address of variable in R1.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>