<?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: Jump Table</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565975#M18243</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 Mar 30 11:47:54 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I seem to remember that there is an assembler directive ".thumb_set" to indicate a function address.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are .syntax unified and .thumb at the top of the file the same in both cases.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;do both assembler command lines have a -thumb switch?&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;ldrr12, =LibSetTimer; trampoline
bxr12;
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;works for me on a 1788 where LibSetTimer is a .thumb_func declared local function (in an internal SRAM section).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just thoughts, Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 00:56:23 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T00:56:23Z</dc:date>
    <item>
      <title>Jump Table</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565974#M18242</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 Mar 30 09:22:31 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I wrote some code for the LPC11xx, which included a jump table&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;noswitch:LDR R3,=progtable
LDR R3,[R3,R2]
BX R3
@ ------------------------------------------------------------------------------------
.align
progtable:.word spare
.word spare
.word scroll
.word fill
.word randomsound
.word random
.word manual&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And then I copied it to a piece of LPC13xx code&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;ADR R0,modetable
LDR R10,[R0,R2,LSL #2]
BX R10&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;modetable:.word mode0LED
.word mode1LED
.word mode2LED
.word mode3LED
.word mode4LED
.word mode5LED
.word mode6LED
.word mode7LED&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The LPC11 code was assembled with bit zero set in the jump table, but the LPC13 code assembled with bit zero clear, so that when the jump was taken the processor attempted an illegal change to ARM mode, and crashed with a hard fault exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;.thumb_func was used correctly on both occasions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Comments please?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565974#M18242</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Jump Table</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565975#M18243</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 Mar 30 11:47:54 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I seem to remember that there is an assembler directive ".thumb_set" to indicate a function address.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are .syntax unified and .thumb at the top of the file the same in both cases.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;do both assembler command lines have a -thumb switch?&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;ldrr12, =LibSetTimer; trampoline
bxr12;
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;works for me on a 1788 where LibSetTimer is a .thumb_func declared local function (in an internal SRAM section).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just thoughts, Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565975#M18243</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Jump Table</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565976#M18244</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 Mar 30 12:21:14 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I just added this&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;
fn SwitchTest

adrr3, JumpTbl
ldrr10, [r3, r0, lsl 2]
bxr10

JumpTbl:

.wordReadSwitches
.wordDebugSwitches
.wordSetLeds
.wordSetActLed
.wordSetFaultLed


fe SwitchTest

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;fn/fe are macros&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;
.macrofn n
.type\n, %function
.func\n
.thumb_Func
\n:
.endm

.macrofe n
.endfunc
.size\n, .-\n
.align2,0
.endm
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to one of my files. Using existing functions later in the file&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Command line from the log file&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;
C:/Dev/NXP/tools/bin/arm-none-eabi-as -mcpu=cortex-m3 -mthumb -g3 -I. -o LibIO.o LibIO.s
--------------
C:/Dev/NXP/tools/bin/arm-none-eabi-size LibIO.o
&amp;nbsp;&amp;nbsp; text&amp;nbsp;&amp;nbsp; data&amp;nbsp;&amp;nbsp;&amp;nbsp; bss&amp;nbsp;&amp;nbsp;&amp;nbsp; dec&amp;nbsp;&amp;nbsp;&amp;nbsp; hexfilename
&amp;nbsp;&amp;nbsp;&amp;nbsp; 208&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 208&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d0LibIO.o
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Disassembly shows that the thumb bit is being set.&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;
00010a50 SwitchTest:
&amp;nbsp;&amp;nbsp; 10a50:a301&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addr3, pc, #4; (adr r3, 10a58 JumpTbl)
&amp;nbsp;&amp;nbsp; 10a52:f853 a020 ldr.wr10, [r3, r0, lsl #2]
&amp;nbsp;&amp;nbsp; 10a56:4750&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bxr10

00010a58 JumpTbl:
&amp;nbsp;&amp;nbsp; 10a58:00010a6d .word0x00010a6d
&amp;nbsp;&amp;nbsp; 10a5c:00010a75 .word0x00010a75
&amp;nbsp;&amp;nbsp; 10a60:00010a7d .word0x00010a7d
&amp;nbsp;&amp;nbsp; 10a64:00010aa1 .word0x00010aa1
&amp;nbsp;&amp;nbsp; 10a68:00010ab1 .word0x00010ab1

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For what it is worth.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I use external build via my own makefile and linker script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: Bloody forum removed labels because of angle brackets - edited them out from the disassembly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit Again: I am using the tool chain that came with IDE 6.?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[Because the latest assembler started using wide branches for local jumps all of a sudden. (No explanation either!)]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I use IDE 7 for debugging,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565976#M18244</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Jump Table</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565977#M18245</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 Mar 30 13:02:19 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for that. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Just for a laugh, I changed the .cpu cortex-m0 statement in my first program to .cpu cortex-m3 and recompiled it; and guess what?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The jump table values remained ODD. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately I can't try the converse, as I have some M3-exclusive instructions in the program.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I noticed the thing about the 32-bit instructions for all the branch instructions. I added .n with find-and-replace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another thing that strikes me as odd is that in my M0 program, the text editor has changed all the labels and assembler directives to purple, and in my M3 program all the text is black. I don't know what setting is involved here, but I wonder what would happen if I changed it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And something else - if I put the jump table in the .rodata section, then the ADR instruction can't find it and compiles to SUBS R10,PC,#4&amp;nbsp; but LDR = has no problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The ultimate solution if I can't reach a sensible explanation is to add +1 to all the jump table values!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565977#M18245</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Jump Table</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565978#M18246</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 Mar 30 16:12:53 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;ADR is a special assembler mnemonic for add/sub pc constant.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It has a limited range.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try ADRL. this uses two opcodes and has a larger range.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The LDR =xxx construct places a constant close by (within 4K?) in the code stream (where it won't get accidentally executed)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and uses an LDR rx, [PC, zz]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't use the IDE editor (and would disable syntax colouring any way) so I can't advise on that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I seems that your m3 code source is being mis-diagnosed as something else.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would double check the start of file directives, the assembler switches, and even the file extension case.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you on unix perhaps?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565978#M18246</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Jump Table</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565979#M18247</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 Tue Mar 31 02:35:07 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Found it! (Daft problem)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I forgot the .text directive after the code-protect-word section. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems a bit odd that everything else worked fine!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I like ADR - it's somehow "neater" than the "LDR =" solution which puts the data in the literal pool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the M3 it can set bit 0, but you have to write ADR R0,label+1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the M0 it's rather a chocolate teapot of an instruction, as it can only generate even addresses, and it can't refer to labels in other sections (if the address it is trying to generate is in .rodata then it fails), so you can neither use it to refer to data tables, nor to jump tables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've also found out how what makes the editor colour the labels purple.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When setting up a new project.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I start with the .c file that is automatically generated with the project, delete its contents and change its name to .s then all the text is black.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I delete the .c file and then add another file File-&amp;gt;new-&amp;gt;other-&amp;gt;general file, and call it .s then it colours the labels and assembler directives; but it makes no difference to how the assembler operates/&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Jump-Table/m-p/565979#M18247</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:26Z</dc:date>
    </item>
  </channel>
</rss>

