<?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 Basic doubts in assembly programming in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-doubts-in-assembly-programming/m-p/159885#M2624</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;I am programming on msc8144, sc3000 architecture.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; In assembly programming can someone explain stack based calling convention?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mainly&amp;nbsp; I would like to know how offsets (from stack pointer) for input arguments and local variables is computed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN&gt;void f1()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;word16 ar1[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;word16 ar2[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;word16 ar3[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;word16 i,j,k;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;/* function body*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;f2(ar1[ ], ar2[ ], ar3[ ], i, j ,k);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;/* function body*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;f2(word16 a1[ ], word16 a2[ ], word16 a3[ ], word16 i, word16 j, word16 k)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;word16 b1[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;word16 b2[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;word16 b3[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/*function body*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN&gt;Now if I want to write function f2 in assembly, how to create memory to store temporary arrays b1, b2, b3.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;how to access input arguments to the function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be helpful if someone can provide resource links, where assembly programming examples are given.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Naveen&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Oct 2007 19:21:19 GMT</pubDate>
    <dc:creator>createdon2003</dc:creator>
    <dc:date>2007-10-31T19:21:19Z</dc:date>
    <item>
      <title>Basic doubts in assembly programming</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-doubts-in-assembly-programming/m-p/159885#M2624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;I am programming on msc8144, sc3000 architecture.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; In assembly programming can someone explain stack based calling convention?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mainly&amp;nbsp; I would like to know how offsets (from stack pointer) for input arguments and local variables is computed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN&gt;void f1()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;word16 ar1[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;word16 ar2[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;word16 ar3[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;word16 i,j,k;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;/* function body*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;f2(ar1[ ], ar2[ ], ar3[ ], i, j ,k);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;/* function body*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;f2(word16 a1[ ], word16 a2[ ], word16 a3[ ], word16 i, word16 j, word16 k)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;word16 b1[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;word16 b2[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;word16 b3[ ];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/*function body*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN&gt;Now if I want to write function f2 in assembly, how to create memory to store temporary arrays b1, b2, b3.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;how to access input arguments to the function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be helpful if someone can provide resource links, where assembly programming examples are given.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Naveen&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2007 19:21:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-doubts-in-assembly-programming/m-p/159885#M2624</guid>
      <dc:creator>createdon2003</dc:creator>
      <dc:date>2007-10-31T19:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Basic doubts in assembly programming</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-doubts-in-assembly-programming/m-p/159886#M2625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For StarCore there is a ABI defining how parameters should be passed to a function.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Please look at {Install}\Help\PDF\MNSC100ABI.pdf chapter "1.6 Function Calling Sequence".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Around allocating space for local variable, you need to reserve some space on the stack.&lt;/DIV&gt;&lt;DIV&gt;I would recommend you to check "Keep .sl File" check box in the Compiler panel and to look at how the compiler is managing the local variables.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Alternatively you can write your function in inline assembly. Please refer to {Install}\Help\PDF\StarCore_C_Compiler_User_Guide.pdf chapter "Mixing C, Assembly Code".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I hope this helps.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2007 15:25:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Basic-doubts-in-assembly-programming/m-p/159886#M2625</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2007-11-02T15:25:59Z</dc:date>
    </item>
  </channel>
</rss>

