<?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 LJMP with variable address?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/13799/how-to-use-ljmp-with-variable-address</link><description> I have a 16-bit address in the A register. I need to make a long jump 
to this address, however it seems there is no way to do this with 
assembly code. By looking at some assembly produced by Keil, when 
they want to do this type of jump then end up</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/141149?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2000 07:37:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:dac89ea0-5987-4017-9904-cc7ad9e3b2dc</guid><dc:creator>Ted Dubroff</dc:creator><description>&lt;p&gt;&lt;i&gt;I hope your returning with RETI not RET in those functions your calling from your ISR. If you don&amp;#39;t RETI you&amp;#39;ll never get another interrupt until you reset (or stumble across a RETI).&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
I am.  Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/137544?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2000 19:58:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:36234664-09c7-4e6b-a884-583f4dfa1e52</guid><dc:creator>Mark Odell</dc:creator><description>&lt;p&gt;I hope your returning with RETI not RET in those functions your calling from your ISR. If you don&amp;#39;t RETI you&amp;#39;ll never get another interrupt until you reset (or stumble across a RETI).&lt;br /&gt;
&lt;br /&gt;
- Mark&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/129649?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2000 17:19:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b7572b18-6330-43f5-b905-eefc786c3c25</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;That&amp;#39;s why in the assembly code I posted earlier left the MCU with nothing modified at the time of the &amp;quot;jump&amp;quot;.  If you had a single variable of &amp;quot;bit&amp;quot; type that holds the boot/mission status you could do a bit test (which doesn&amp;#39;t disturb the MCU state) and &amp;quot;jump&amp;quot; accordingly to boot or mission ISR&amp;#39;s.  With no MCU state disturbed using this technique, you can write the ISR&amp;#39;s without worrying about what&amp;#39;s been modified at entry.&lt;br /&gt;
&lt;br /&gt;
More ideas, which by now you&amp;#39;ve got plenty of.&lt;br /&gt;
&lt;br /&gt;
--Dan Henry&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/121566?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2000 16:52:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:62e631af-277a-4029-9348-02f357e1eb4c</guid><dc:creator>Ted Dubroff</dc:creator><description>&lt;p&gt;Good point.  I&amp;#39;ll have to modify my code to account for the registers used in the functions.  Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/109773?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2000 16:43:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:266f0d89-0864-4ca9-85ec-c4cd215f181e</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;Ted,&lt;br /&gt;
&lt;br /&gt;
You may be posting only sections of the code, so what I&amp;#39;m not seeing may well be present, but...&lt;br /&gt;
&lt;br /&gt;
Are you saving the interrupted states of PSW, ACC, R6, R7, DPTR, and whatever registers missionCodeIsRunning() also modifies?  Do both uart0_isr() and the destination ISR jumped to through DPTR know to how to restore these same registers?&lt;br /&gt;
&lt;br /&gt;
--Dan Henry&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/84026?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2000 13:53:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8277ce66-1cbe-49ea-9755-b349e5161327</guid><dc:creator>Ted Dubroff</dc:creator><description>&lt;p&gt;Hey Dan, I ended up doing it this way:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
        UART_0_INT      EQU     23h 

; . . .

        CSEG    AT      UART_0_INT
        LJMP            UART_0_ISR

; . . .

UART_0_ISR:
;       if (!missionCodeIsRunning()) {
;               bootloader_uart0_isr();
;       else
;               mission_uart0_isr();
;       }
        LCALL   _?missionCodeIsRunning
        MOV     A,R7
        JZ      bootloader_uart0
        JMP     mission_uart0

        bootloader_uart0:
        LJMP    uart0_isr

        mission_uart0:
        LCALL   _?goAddr
        MOV     DPH,R6
        MOV     DPL,R7
        CLR     A
        ADD     A, #UART_0_INT
        JMP     @A+DPTR&lt;/pre&gt;
I had to ensure that my bootloader code specified NOINTVECTOR as you suggested in an earlier post.  Thanks for your help.  I still have one more problem, which I posted in another thread.&lt;br /&gt;
&lt;br /&gt;
-Ted&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/53456?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2000 13:45:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ff4ef2ca-36bd-467c-b905-a793234ea4fe</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;If Ted is going to be doing this from C interrupt function to C interrupt function, he&amp;#39;s still going to have problems, I think.  FWIW, I&amp;#39;ve posted a means to re-vector an ISR in Ted&amp;#39;s other thread.&lt;br /&gt;
&lt;br /&gt;
--Dan Henry&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/53446?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2000 13:32:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:df4fd763-a010-4eac-b827-baeac4b9a3ee</guid><dc:creator>Ted Dubroff</dc:creator><description>&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use LJMP with variable address?</title><link>https://community.arm.com/thread/37041?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2000 10:47:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:90f68515-f959-4fd3-8413-7479db8f02fd</guid><dc:creator>Michael Podgouzov</dc:creator><description>&lt;p&gt;If you speak about the 51th controller and you need to make a jump to an explicit 16-bit address, you may load this address into DPTR (DPH, DPL), clear your accumulator and use JMP @A+DPTR.&lt;br /&gt;
              Michael.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>