<?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>topic Inline Assembly Help - Cortex M0 in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562405#M16722</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by moogde on Thu Sep 17 09:05:09 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;first of all please apologize if my questions are trivial... Its my first time using C with Microcontrollers (which works quite well actually), I'm currently switching to ARM (LPC1115) from the 8-Bit-AVR side and was programming those in Assembler (only). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am reading the book "The Definitive Guide to the Cortex M0" at the moment from Joseph Yiu and try to define an assembly function within C Code, but the following code (thats suggested in the book) can't be compiled:&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;
__asm uint32_t my_add_e(uint32_t x1, uint32_t x2, uint32_t x3, uint32_t x3)
{
ADDSR0, R0, R1
ADDSR0, R0, R2
ADDSR0, R0, R3
BXLR
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the book it says that the first 4 Parameters when calling this function are stored by the compiler within R0-R4 and the return value has to be in r0 (and names some other restrictions in using this technique, too). Is there something different in the syntax of the LPCXpresso Software? The compiler says "expected '(' before 'uint32_t'" right at the first line. What would be the correct way to do this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I understand that there is the possibility to use the __asm("")-Syntax. I've experimented with this a lot, and partly, it did work. Maybe you could help me with this bit of code here, I'm trying to use inline Assembly to give the shortest possible pulse on a port pin of the Cortex.&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;
uint32_t addr= &amp;amp;LPC_GPIO3-&amp;gt;DATA;
uint32_t on= 0x04;
uint32_t off= 0x00;

__asm("str %[on],&amp;nbsp; %[addr]\n\t"
"str %[off], %[addr]"

:&amp;nbsp; : [addr] "r" (addr), [on] "r" (on), [off] "r" (off)
);

&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 compiler gives me the error "Error: r15 based store not allowed -- `str r2,r3'" on that (what does this error mean?). Is there another way to pass Adresses or Data from C-Area to the Assembler-Area - and vice versa - instead of using registers like shown (or at least like I've tried to do it) in this code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Third question: Is there a way to have a look at the disassembly of the generated code, if the project compiles without errors? I'm coming from the AVR-World and am very interested in how the compiler actually translates this stuff fo Assembly. My aim is to be able to do timing-critical stuff on that platform as I'm used to do with the 8 Bit Controllers. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-moogde&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:40:27 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T23:40:27Z</dc:date>
    <item>
      <title>Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562405#M16722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by moogde on Thu Sep 17 09:05:09 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hey there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;first of all please apologize if my questions are trivial... Its my first time using C with Microcontrollers (which works quite well actually), I'm currently switching to ARM (LPC1115) from the 8-Bit-AVR side and was programming those in Assembler (only). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am reading the book "The Definitive Guide to the Cortex M0" at the moment from Joseph Yiu and try to define an assembly function within C Code, but the following code (thats suggested in the book) can't be compiled:&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;
__asm uint32_t my_add_e(uint32_t x1, uint32_t x2, uint32_t x3, uint32_t x3)
{
ADDSR0, R0, R1
ADDSR0, R0, R2
ADDSR0, R0, R3
BXLR
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the book it says that the first 4 Parameters when calling this function are stored by the compiler within R0-R4 and the return value has to be in r0 (and names some other restrictions in using this technique, too). Is there something different in the syntax of the LPCXpresso Software? The compiler says "expected '(' before 'uint32_t'" right at the first line. What would be the correct way to do this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I understand that there is the possibility to use the __asm("")-Syntax. I've experimented with this a lot, and partly, it did work. Maybe you could help me with this bit of code here, I'm trying to use inline Assembly to give the shortest possible pulse on a port pin of the Cortex.&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;
uint32_t addr= &amp;amp;LPC_GPIO3-&amp;gt;DATA;
uint32_t on= 0x04;
uint32_t off= 0x00;

__asm("str %[on],&amp;nbsp; %[addr]\n\t"
"str %[off], %[addr]"

:&amp;nbsp; : [addr] "r" (addr), [on] "r" (on), [off] "r" (off)
);

&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 compiler gives me the error "Error: r15 based store not allowed -- `str r2,r3'" on that (what does this error mean?). Is there another way to pass Adresses or Data from C-Area to the Assembler-Area - and vice versa - instead of using registers like shown (or at least like I've tried to do it) in this code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Third question: Is there a way to have a look at the disassembly of the generated code, if the project compiles without errors? I'm coming from the AVR-World and am very interested in how the compiler actually translates this stuff fo Assembly. My aim is to be able to do timing-critical stuff on that platform as I'm used to do with the 8 Bit Controllers. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-moogde&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562405#M16722</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562406#M16723</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 Mon Sep 21 02:40:26 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem with your first example is that it probably is for the Keil compiler. LPCXpresso uses GCC, which doesn't understand the syntax where the whole body of the function is in assembly language.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the second example I think you need square brackets around %[addr] (look up the STR instruction in the ARM documentation).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can let the compiler generate an assembly listing by passing it the right options:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.lpcware.com%2Fcontent%2Fforum%2Foutput-assembler-file-when-compile" rel="nofollow" target="_blank"&gt;https://www.lpcware.com/content/forum/output-assembler-file-when-compile&lt;/A&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562406#M16723</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562407#M16724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by moogde on Tue Sep 22 12:26:33 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Wow, thank you very much, this helped a lot!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First of all let me show you the modified code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
uint32_t addr= &amp;amp;LPC_GPIO3-&amp;gt;DATA;
uint32_t on= 0x04;
uint32_t off= 0x00;

LPC_GPIO3-&amp;gt;DATA = on;
LPC_GPIO3-&amp;gt;DATA = off;

__asm("str %[on],&amp;nbsp; [%[addr]]\n\t"
"str %[off], [%[addr]]"
:&amp;nbsp; : [addr] "r" (addr), [on] "r" (on), [off] "r" (off)
);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please find the measured result this code produces on the hardware attached to this comment. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;[img]&lt;/SPAN&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.lpcware.com%2Fsystem%2Ffiles%2Ffasttrigger.jpg%5B%2Fimg%5D" rel="nofollow noopener noreferrer" target="_blank"&gt;https://www.lpcware.com/system/files/fasttrigger.jpg[/img]&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...the slowness of the first pulse is no wonder if I take a look at what the compiler actually does (the disassembly of the C line "LPC_GPIO3-&amp;gt;DATA = on"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
 539 0086 0D4A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldrr2, .L28+24
 540 0088 0D4B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldrr3, .L28+28
 541 008a 7968&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldrr1, [r7, #4]
 542 008c D150&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strr1, [r2, r3]
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far, so good &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please let me ask you some other questions now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. If I'm writing something like in the example "uint32_t on= 0x04;", why is the Compiler not just using a local register in this function, which would be much faster here, why is he putting this into its RAM? Can I suggest or force the compiler to just a register, locally, for this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. I was using the compiler options to generate a list file, as you suggested. I finally found it on the hard disk's debug directory, but it was not shown on the internal project explorer's debug directory. Why is that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. What is a good / or the "correct" editor to explore the disassembly list file? When I open it with the windows explorer, it opens in Microsoft Visual Studio &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4. What kind of ressources am I allowed to use within the __asm()-Definition? Can I use all the registers? Do everything? (and the compiler takes care that there will be no conflicts with what he does?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5. What if I want to load the adress in the above example directly - within the inline assembler, not just loading it in C, and then passing the register to the assembly routine? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like "ldrr3, &amp;amp;LPC_GPIO3-&amp;gt;DATA"... You get the idea &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;6. uint32_t addr= &amp;amp;LPC_GPIO3-&amp;gt;DATA;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gets translated to&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ldrr3, .L28+20&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so the compiler seems to be storing this adress as one number in flash and loads it here into r3. But: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_GPIO3-&amp;gt;DATA = on;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gets resolved into&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ldrr2, .L28+24&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ldrr3, .L28+28&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and [r2+r3] are then used to store the data. My assumption is that this is the "LPC_GPIO3" Base adress and the "DATA"-Offset of the Adress (am I getting this correct?) My question: Is there a way to write directly to the final adress in C? (like on the &amp;amp;LPC_GPIO3-&amp;gt;DATA example?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that this is a lot of questions, I hope its okay! Thank you very much for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562407#M16724</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562408#M16725</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 Wed Sep 23 01:10:57 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: moogde&lt;/STRONG&gt;&lt;BR /&gt;1. If I'm writing something like in the example "uint32_t on= 0x04;", why is the Compiler not just using a local register in this function, which would be much faster here, why is he putting this into its RAM?&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;What is your optimization setting?&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;2. I was using the compiler options to generate a list file, as you suggested. I finally found it on the hard disk's debug directory, but it was not shown on the internal project explorer's debug directory. Why is that?&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;The project explorer filters out some files, use the Navigator if you want to see everything.&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;3. What is a good / or the "correct" editor to explore the disassembly list file?&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Any good text editor, I use Emacs. You could also open it in Eclipse, but beware of very large files, Eclipse may hang due to lack of memory.&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;When I open it with the windows explorer, it opens in Microsoft Visual Studio ;-)&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;You can change that in the Windows properties of a file.&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;4. What kind of ressources am I allowed to use within the __asm()-Definition? Can I use all the registers? Do everything? (and the compiler takes care that there will be no conflicts with what he does?)&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Read the GCC documentation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fgcc.gnu.org%2Fonlinedocs%2Fgcc%2FUsing-Assembly-Language-with-C.html" rel="nofollow" target="_blank"&gt;https://gcc.gnu.org/onlinedocs/gcc/Using-Assembly-Language-with-C.html&lt;/A&gt;&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;6. uint32_t addr= &amp;amp;LPC_GPIO3-&amp;gt;DATA;&amp;nbsp; &lt;BR /&gt;gets translated to&amp;nbsp;&amp;nbsp; &lt;BR /&gt;ldrr3, .L28+20&lt;BR /&gt;so the compiler seems to be storing this adress as one number in flash and loads it here into r3. But: &lt;BR /&gt;LPC_GPIO3-&amp;gt;DATA = on;&lt;BR /&gt;gets resolved into&lt;BR /&gt;ldrr2, .L28+24&lt;BR /&gt;ldrr3, .L28+28&lt;BR /&gt;and [r2+r3] are then used to store the data. My assumption is that this is the "LPC_GPIO3" Base adress and the "DATA"-Offset of the Adress (am I getting this correct?) My question: Is there a way to write directly to the final adress in C? (like on the &amp;amp;LPC_GPIO3-&amp;gt;DATA example?)&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;No. Immediate values are limited to 8 bits shifted (or rotated?) by an even number of bits, so you can't put an arbitrary address there. Using an address in flash is the standard way to do it on ARM, in assembly you can use the ldr rN,=value pseudoinstruction for that. Some newer processors can also load 32 bits by using two instructions for loading the two 16 bit halfwords, which uses the same memory and usually is faster, because of prefetching / caching (but not always).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should be explained in the book, BTW (it is in the Definitive Guide to the Cortex-M3/M4).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;You can also get the documents from ARM, e.g. &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Finfocenter.arm.com%2Fhelp%2Findex.jsp%3Ftopic%3D%2Fcom.arm.doc.dui0553a%2Findex.html" rel="nofollow" target="_blank"&gt;http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/index.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562408#M16725</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562409#M16726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by moogde on Fri Sep 25 07:53:08 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for pointing out the right directions! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll be trying out some of that stuff. Coming from the assembler, I think the possibility to explicitly locate variables in some global registers might be important. In ASM I'll just use a few registers for temporarily stuff within functions (these registers are never touched by interrupt routines). So I think this might help here, too, because it means that some "fast access" standard variables are always there to use. They then also could be used to transfer data to and from functions. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But of course i'll check if that really makes sense in the end with the disassembly. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I played with the Optimization-Settings a bit (didn't know that those existed yet), and it helped a lot in terms of execution speed, but I also missed some of my function's code at the highest optimization setting in the listing file. Is it possible that the Compiler at higher optimization settings is actually generating the same subroutine five times, when it gets called 5 times in the source code? (To omit all the additional steps for the calls, returns)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(But thats not a real important question, I'll find this out myself probably.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot so far! I might post other questions when they occur :)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562409#M16726</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562410#M16727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Fri Sep 25 08:10:09 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: moogde&lt;/STRONG&gt;&lt;BR /&gt;Is it possible that the Compiler at higher optimization settings is actually generating the same subroutine five times, when it gets called 5 times in the source code? (To omit all the additional steps for the calls, returns)&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course it's inlining&amp;nbsp; :) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See:&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%2Fstackoverflow.com%2Fquestions%2F1626248%2Fdoes-gcc-inline-c-functions-without-the-inline-keyword" rel="nofollow" target="_blank"&gt;http://stackoverflow.com/questions/1626248/does-gcc-inline-c-functions-without-the-inline-keyword&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562410#M16727</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562411#M16728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by moogde on Fri Sep 25 10:45:26 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Wow, okay, THAT is inlining. Got it :D What happens if there is not enough Flash Memory to do it? Will it automatically detect that? (just being curious here)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562411#M16728</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562412#M16729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Fri Sep 25 11:27:26 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: moogde&lt;/STRONG&gt;&lt;BR /&gt;What happens if there is not enough Flash Memory to do it? Will it automatically detect that?)&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, you will receive something like:&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;d:/nxp/lpcxpresso_7.9.2_493/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: LPC11_DEMO.axf [color=#f00]section `.text' will not fit in region `MFlash16'[/color]&lt;BR /&gt;d:/nxp/lpcxpresso_7.9.2_493/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: LPC11_DEMO.axf[color=#f00] section `.bss' will not fit in region `RamLoc4'[/color]&lt;BR /&gt;d:/nxp/lpcxpresso_7.9.2_493/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region `MFlash16' overflowed by 7932 bytes&lt;BR /&gt;d:/nxp/lpcxpresso_7.9.2_493/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region `RamLoc4' overflowed by 2540 bytes&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in order to rethink your optimization settings&amp;nbsp; :) &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562412#M16729</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Inline Assembly Help - Cortex M0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562413#M16730</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 Sep 26 00:27:11 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: moogde&lt;/STRONG&gt;&lt;BR /&gt;I think the possibility to explicitly locate variables in some global registers might be important.&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;In C there is the 'register' keyword, but it is mostly ignored by modern compilers.&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;In ASM I'll just use a few registers for temporarily stuff within functions (these registers are never touched by interrupt routines). So I think this might help here, too, because it means that some "fast access" standard variables are always there to use. They then also could be used to transfer data to and from functions. &lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;To understand how registers are allocated you should read about the ABI (AAPCS, ARM document IHI0042). In fact, on Cortex-M they designed the interrupt handling so that interrupts behave like C functions, so you don't need to do anything special (e.g. on ARM7 you need an assembly wrapper around the interrupt).&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:40:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Inline-Assembly-Help-Cortex-M0/m-p/562413#M16730</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:40:32Z</dc:date>
    </item>
  </channel>
</rss>

