<?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>LPCXpresso IDE中的主题 Re: Cortex M3 ADR instruction</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547002#M9922</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Mon Jul 20 08:21:29 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Ian.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is a subtle difference between LDR Rx,=xxx abd ADR/ADRL.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LDR reads a &lt;/SPAN&gt;&lt;I&gt;value&lt;/I&gt;&lt;SPAN&gt; from a pc relative offset. The value is often a big constant, but can be an address of something.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ADR sets a register to an &lt;/SPAN&gt;&lt;I&gt;address&lt;/I&gt;&lt;SPAN&gt; relative to the current pc. This is useful for tables, messsage strings etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that TBB uses &lt;/SPAN&gt;&lt;I&gt;byte&lt;/I&gt;&lt;SPAN&gt; times two offsets so is limited to quite short jumps. TBH uses &lt;/SPAN&gt;&lt;I&gt;half word&lt;/I&gt;&lt;SPAN&gt; times two offsets.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;An example from my own LPCXpresso (i.e. gcc assembler) ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
;---------------------------------------;
2:tbb[pc, r0]; else branch
T0:.byte(T10-T0)/2; listen
.byte(T20-T0)/2; syn received
.byte(T30-T0)/2; established
.byte(T40-T0)/2; last ack
.align 2,0; align even

;---------------------------------------;
; LISTEN;
;---------------------------------------;
T10:tstr1, tcpSyn;
beq9f; not syn, not interrested

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; ...
b9f; return

;---------------------------------------;
; SYN RCVD;
;---------------------------------------;
T20:tstr1, tcpSyn; another syn, did they miss my ack?
bne11b; apparently -- resend the ack

etc.
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that R0 (can be any register) must be range checked before using it as a jump index!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Note also, that if there happen to be an odd number of branches, the following opcodes will not be on 16-bit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;boundaries -- hence the align!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps you a little bit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 22:01:21 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T22:01:21Z</dc:date>
    <item>
      <title>Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546994#M9914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Fri Jul 17 06:55:33 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6aa:f000 fe32 bl1312 &amp;lt;wcmd&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6ae:f2af 0004 subwr0, pc, #4
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6b2:2100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movsr1, #0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6b4:f000 fe9c bl13f0 &amp;lt;wmsg&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6b8:f20f 2025 addwr0, pc, #549; 0x225
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6bc:2180&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movsr1, #128; 0x80
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6be:f000 fe97 bl13f0 &amp;lt;wmsg&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6c2:2400&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movsr4, #0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6c4:f45f 65fd movs.wr5, #2024; 0x7e8&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This bit of code is assembled from:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BL wcmd
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADR R0,msg0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MOVS R1,#0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ top line left display
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BL wmsg
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADR R0,msg22
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MOVS R1,#0x80
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BL wmsg&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;but the label msg0 is at address 0x1BD0 and msg22 is at 0x1DF9&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;shouldn't it have flagged an "offset out of range" error?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546994#M9914</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546995#M9915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Fri Jul 17 07:17:55 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Dunno. Can't tell from a short snippet. Would need to see the entire file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Presumably, though, you are not seeing the behavior you expected, so what does R0 contain when you step through the code?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546995#M9915</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546996#M9916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Fri Jul 17 07:35:23 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;R0 contained 0x6AC which is PC-4 like the disassembly listing says.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It should have contained 0x1BD0, though it can't because that's more than ±4095 away.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;00001bd0 &amp;lt;msg0&amp;gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 1bd0:20202020 .word0x20202020
...
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546996#M9916</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546997#M9917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Fri Jul 17 09:15:39 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Ian.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ADR is an assembler construct to get an address value 'near' the current code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you see, it does this by adding or subtracting a constant from the current PC (i.e current instruction + 8 -- or is it + 4?).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you may know the size of constants than may be embedded in an instruction is limited -- and there are crazy rules about&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;shifting a 8-bit literal up to make *some* bigger values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd guess that the location of your 'msg0' etc. are too far and you are getting the same effect as truncating words to bytes etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[I'd have thought that the assembler would throw an error, but ...]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HOWEVER, there is also a long form of 'ADR' called 'ADRL' naturally. This uses two basic instructions to do the add/subtract&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from the current (ish) PC. If only one is actually neccessary, the second will be a NOP.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not clear about the acceptable ranges for either the standard ADR or the longer (more expensive) ADRL -- maybe it is&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;buried in the GNU assembler manual, or -- more likely -- in the ARM ARCHITECTURE V 7M manual.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that yields some insight and or actual help -- Cheers, Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546997#M9917</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546998#M9918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Sat Jul 18 05:34:02 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears to assemble to the ADD Rn, Rm, #immed12 instruction, where m is 15 (the program counter), so it can get ±4095 from the current (or next) PC location; rather than use the ADD Rn, Rm, &amp;lt;flexible second operand&amp;gt;&amp;nbsp; which has the odd rules about constants.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What bothers me is that it quite happily assembled the WRONG #immed12 value without even telling me, and left me to wonder why my program loaded the data from completely the wrong address.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, the Cortex M0 "ADR" is a complete chocolate teapot - because #immed12 has to have its lowest two bits as zero, it is impossible to use ADR for branch tables because it is impossible to set bit 0 for a proper Thumb branch. I suppose it would be OK for lookup tables, but as they tend to go after the main program in a .rodata section, it tends to be out of range for both M0 and M3.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546998#M9918</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546999#M9919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Sat Jul 18 14:39:47 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ian, did you try "ADRL"?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For jump tables, use TBB or TBH.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/546999#M9919</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547000#M9920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Sat Jul 18 14:45:48 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that ADR/ADRL are only intended for use in the &lt;/SPAN&gt;&lt;I&gt;same&lt;/I&gt;&lt;SPAN&gt; assembler section.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Linker relocation after the assembly phase will probably screw you over if cross-section offset!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547000#M9920</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547001#M9921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Mon Jul 20 01:50:55 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm slightly puzzled that ADR complies the wrong value but LDR Rn,=immed gets it right even when the label is in a different section. Compared to ADRL, LDR Rn,= is about as efficient in both time and space!&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;For jump tables, use TBB or TBH.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm slowly learning the additional M3 instructions - I've mastered ITT but TBH looked complicated, because the branches are relative, so the branch table has to have entries which calculate the relative branch from the absolute address and the present location. A list of absolute destinations seemed better for future readability!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Joseph Yiu's examples were for a different assembler, but presumably&amp;nbsp; it has to look something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;branchtable: .hword (destination1-branchtable)/2, (destination2-branchtable)/2 &lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;etc. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547001#M9921</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547002#M9922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Mon Jul 20 08:21:29 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Ian.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is a subtle difference between LDR Rx,=xxx abd ADR/ADRL.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LDR reads a &lt;/SPAN&gt;&lt;I&gt;value&lt;/I&gt;&lt;SPAN&gt; from a pc relative offset. The value is often a big constant, but can be an address of something.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ADR sets a register to an &lt;/SPAN&gt;&lt;I&gt;address&lt;/I&gt;&lt;SPAN&gt; relative to the current pc. This is useful for tables, messsage strings etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that TBB uses &lt;/SPAN&gt;&lt;I&gt;byte&lt;/I&gt;&lt;SPAN&gt; times two offsets so is limited to quite short jumps. TBH uses &lt;/SPAN&gt;&lt;I&gt;half word&lt;/I&gt;&lt;SPAN&gt; times two offsets.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;An example from my own LPCXpresso (i.e. gcc assembler) ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
;---------------------------------------;
2:tbb[pc, r0]; else branch
T0:.byte(T10-T0)/2; listen
.byte(T20-T0)/2; syn received
.byte(T30-T0)/2; established
.byte(T40-T0)/2; last ack
.align 2,0; align even

;---------------------------------------;
; LISTEN;
;---------------------------------------;
T10:tstr1, tcpSyn;
beq9f; not syn, not interrested

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; ...
b9f; return

;---------------------------------------;
; SYN RCVD;
;---------------------------------------;
T20:tstr1, tcpSyn; another syn, did they miss my ack?
bne11b; apparently -- resend the ack

etc.
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that R0 (can be any register) must be range checked before using it as a jump index!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Note also, that if there happen to be an odd number of branches, the following opcodes will not be on 16-bit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;boundaries -- hence the align!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps you a little bit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547002#M9922</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547003#M9923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Sat Aug 01 10:32:40 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks. I wasn't quite sure from the manual exactly how it worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Having had another look at the ARM Cortex M3 manual, I would think that&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;LDR R0,=tableaddress
LDR PC,(R0,R1,LSL#2)&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;would be the easiest way to do it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It still rather puzzles me why ARM code is switched off on the Cortex devices. Surely, there must be some thumb-to-arm lookup table to make it all work, so why not allow it to be programmed in ARM code? I'd much rather write ARM code than the restricted Thumb code, (although much less restricted on the M3) - and I still prefer either to C. (By the way, Mike, last year you suggested I tried some C programming and I still haven't - my excuse is that all the projects I have done have been very timing-conscious.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd still like an explanation from the powers-that-be (Are you reading this, NXP?) as to why the ADR instruction assembles the wrong offset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547003#M9923</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547004#M9924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cfb on Sat Aug 01 18:26:22 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: IanB&lt;/STRONG&gt;&lt;BR /&gt;It still rather puzzles me why ARM code is switched off on the Cortex devices. Surely, there must be some thumb-to-arm lookup table to make it all work, so why not allow it to be programmed in ARM code?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wouldn't have thought so. I was under the impression that the Cortex instruction set was only similar to ARM at the assembly language level. When rewriting the Oberon compiler code-generator for Cortex-M3 we found that the bit-patterns of the actual code generated for similar instructions are very different to ARM code. It is not obvious how you could map one onto the other. An interesting read which may give you more insight is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ARM Cortex-M3 Processor Software Development for ARM7TDMI Processor Programmers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.arm.com%2Ffiles%2Fpdf%2FCortex-M3_programming_for_ARM7_developers.pdf" rel="nofollow" target="_blank"&gt;http://www.arm.com/files/pdf/Cortex-M3_programming_for_ARM7_developers.pdf&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547004#M9924</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547005#M9925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpcxpresso-support on Mon Aug 03 01:13:00 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;It still rather puzzles me why ARM code is switched off on the Cortex devices. Surely, there must be some thumb-to-arm lookup table to make it all work, so why not allow it to be programmed in ARM code?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All of the Cortex-M family of devices are native Thumb devices. They execute Thumb directly - there is no ARM mode.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I'd still like an explanation from the powers-that-be (Are you reading this, NXP?) as to why the ADR instruction assembles the wrong offset.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you think there is a problem, please post an example that exhibits the problem. We cannot do anything with snippets - we need&amp;nbsp; the whole project, and a detailed explanation of what you think is wrong.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547005#M9925</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M3 ADR instruction</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547006#M9926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Sat Aug 08 02:30:06 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: IanB&lt;/STRONG&gt;&lt;BR /&gt;It still rather puzzles me why ARM code is switched off on the Cortex devices&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;My guess is that not doing things uses less silicon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Surely, there must be some thumb-to-arm lookup table to make it all work, so why not allow it to be programmed in ARM code?&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Probably not, it would be a lot of overhead compared to decoding instructions directly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;I'd much rather write ARM code than the restricted Thumb code, (although much less restricted on the M3) - and I still prefer either to C.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cortex-M is designed to be programmed in C, not Assembler. So if you do it anyway, you better accept it the way it is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;I'd still like an explanation from the powers-that-be (Are you reading this, NXP?) as to why the ADR instruction assembles the wrong offset.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The powers-that-be in this case is the GNU binutils project, which contains the GNU assembler.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Cortex-M3-ADR-instruction/m-p/547006#M9926</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:23Z</dc:date>
    </item>
  </channel>
</rss>

