<?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 Re: Using assembly in Codewarrior C in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164681#M4728</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Check out some of the project files located in the directory (CodeWarrior Examples). There are some code examples that use a mix of C and assembly.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jun 2008 21:10:19 GMT</pubDate>
    <dc:creator>J2MEJediMaster</dc:creator>
    <dc:date>2008-06-16T21:10:19Z</dc:date>
    <item>
      <title>Using assembly in Codewarrior C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164679#M4726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello Forum members,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am using Codewarrior V4.6 build 6345 for MC9S12GC32CPB16. My project is having some of the files in assembly for speed optimization. These assembly files need to access some constants and variables from C code and viceversa (from assembly to C). How do I pass/retrieve constants, variables to/from C and assembly? Can I use header files (.h) with assembly code for defining constants etc?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks in advance.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2008 20:43:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164679#M4726</guid>
      <dc:creator>SSK</dc:creator>
      <dc:date>2008-06-16T20:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using assembly in Codewarrior C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164680#M4727</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;You can find information about mixing C and assembler in the assembler reference manual.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Please take a look at {Install}\Help\PDF\Assembler_HC12.pdf, in chapter "Using the HC(S)12 Assembler" section "Mixed C and Assembler Applications".&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>Mon, 16 Jun 2008 21:09:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164680#M4727</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-06-16T21:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using assembly in Codewarrior C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164681#M4728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Check out some of the project files located in the directory (CodeWarrior Examples). There are some code examples that use a mix of C and assembly.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2008 21:10:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164681#M4728</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2008-06-16T21:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using assembly in Codewarrior C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164682#M4729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Many thanks forum members.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The assembler manual helped me to use assembly and C with Codewarrior.&lt;/DIV&gt;&lt;DIV&gt;Can I use header file (.h) in assembly code? Some of the&amp;nbsp;examples from Codewarrior directory do use INCLUDE directive but with .INC file. Can this INCLUDE be used with .H files in assembly? Assembler&amp;nbsp;is giving error if I try to use the same. Please clarify the problem.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks in advance.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 13:02:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164682#M4729</guid>
      <dc:creator>SSK</dc:creator>
      <dc:date>2008-06-17T13:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using assembly in Codewarrior C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164683#M4730</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;You cannot include a .h file, which contains ANSI C syntax in an assembly source file.&lt;/DIV&gt;&lt;DIV&gt;You need to convert the declaration you need into something the macro assembler is able to understand.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For HC08 and HC12 you can get some help from the compiler.&lt;/DIV&gt;&lt;DIV&gt;If you use the pragma CREATE_ASM_LISTING ON and CREATE_ASM_LISTING OFF &amp;nbsp;in your ANSI C source file, the compiler can help you in creating an assembly include file containing the corresponding declaration.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Please take a look at the {Install}\Help\PDF\Manual_Compiler_HCI.pdf manual, chapter "Using the Compiler", section "Compiler Pragmas" -&amp;gt; "#pragma CREATE_ASM_LISTING: Create an Assembler Include File Listing" for more information.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you decide to go this way, make sure the ANSI C files are build prior to the assembly source file.&lt;/DIV&gt;&lt;DIV&gt;You can adjust sequence in which the files are built in the project Link Order view.&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>Tue, 17 Jun 2008 18:16:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164683#M4730</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-06-17T18:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using assembly in Codewarrior C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164684#M4731</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;I tried to use the header file in the form of .inc file that is my header file is having some defines. I incorporated these defines in .inc file using EQU. Then I used the saved .inc file in assembly to address the variable. It seems that it is working - no assembler error. Whether this is a correct way to use header file in the form of .inc file in an assembly code?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks in advance.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 19:10:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164684#M4731</guid>
      <dc:creator>SSK</dc:creator>
      <dc:date>2008-06-17T19:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using assembly in Codewarrior C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164685#M4732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Within your .asm file(s), you could export the names of specific assembly sub-routines required to be externally accessible to&amp;nbsp;other files, either .asm or .c, using the XDEF assembler directive.&amp;nbsp;&amp;nbsp;For example,&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;XDEF&amp;nbsp;&amp;nbsp;routine1, routine2&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For any simple global variables&amp;nbsp;defined within&amp;nbsp;a .c&amp;nbsp;file, that need to be imported for use by the assembly code,&amp;nbsp; use the XREF directive.&amp;nbsp; For example,&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; XREF&amp;nbsp; gvar1, gvar2&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;Probably not a good idea to import a structure or a multi-dimensional array.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To provide the equates within the .asm file,&amp;nbsp;for the specific device you are using, you will probably also need the line -&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; &lt;FONT face="Courier New"&gt;INCLUDE&amp;nbsp; "derivative.inc"&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;or the .inc file that is incorporated&amp;nbsp;by the project wizard.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Then within a .c or .h file, you will need prototypes for the assembly routines.&amp;nbsp; For example -&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;extern void *routine1(void);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;When it came to using the sub-routines within a C function, I have previously use inline assembly,&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;__asm&amp;nbsp;&amp;nbsp;JSR&amp;nbsp; routine1;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;but presumably other methods are feasible.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This was previously applied to HCS08 coding, but I assume that the HCS12 will have similar assembler directives.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-06-18&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;12:28 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 21:16:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164685#M4732</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-06-17T21:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using assembly in Codewarrior C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164686#M4733</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;I would say that is the normal way of programming.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You can use any other extension for your assembly include file. Just make sure the content of the included file follows&amp;nbsp;the Assembly language definition.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It should only contain valid assembler directives and/or instructions.&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>Wed, 18 Jun 2008 16:42:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Using-assembly-in-Codewarrior-C/m-p/164686#M4733</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2008-06-18T16:42:08Z</dc:date>
    </item>
  </channel>
</rss>

