<?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: HC908 back end integrating asm+C in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175621#M5675</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can submit a service request to ask for an extension in&amp;nbsp;the compiler.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the URL for submitting a service request:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.freescale.com/webapp/servicerequest.create_SR.framework?regFlag=fromOpenSR" rel="nofollow" target="_blank"&gt;https://www.freescale.com/webapp/servicerequest.create_SR.framework?regFlag=fromOpenSR&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 May 2009 19:45:41 GMT</pubDate>
    <dc:creator>CrasyCat</dc:creator>
    <dc:date>2009-05-06T19:45:41Z</dc:date>
    <item>
      <title>HC908 backend intergrating asm+C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175618#M5672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need fast routines in this case so i built a 32bit timeout checking routine in assembly that is very fast.&lt;/P&gt;&lt;P&gt;It returns a bool in accumulator A and an accordingly set Z flag (condition code).&lt;/P&gt;&lt;P&gt;On use of this routine the compiler thinks it is necessary to test A again:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
&amp;nbsp; 936:&amp;nbsp;&amp;nbsp; if(CheckTimeoutByRef(&amp;amp;Timeout)) { //If timeout:&amp;nbsp; 0000 a600&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [2]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDA&amp;nbsp;&amp;nbsp; @Timeout&amp;nbsp; 0002 5f&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [1]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLRX&amp;nbsp;&amp;nbsp;&amp;nbsp; 0003 cd0000&amp;nbsp;&amp;nbsp; [5]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JSR&amp;nbsp;&amp;nbsp; CheckTimeoutByRef&amp;nbsp; 0006 4d&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [1]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TSTA&amp;nbsp;&amp;nbsp;&amp;nbsp; 0007 270b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [3]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEQ&amp;nbsp;&amp;nbsp; L14 ;abs = 0014&amp;nbsp; 937: &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i tell the compiler that Z is already correctly set ie. that the TSTA instruction is not necessary ? (I know it saves just one instruction.)&lt;/P&gt;&lt;P&gt;The CheckTimeoutByRef&amp;nbsp;function is pure assembly.&lt;/P&gt;&lt;P&gt;Add something to the function definition ? A pragma ? Or .... ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:24:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175618#M5672</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2020-10-29T09:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: HC908 back end integrating asm+C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175619#M5673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is not possible. When you are calling a function the compiler expects it to follow the calling convention defined by&amp;nbsp;the compiler.&lt;/P&gt;&lt;P&gt;This calling convention is described in the "Compiler_HC08.pdf" manual chapter "Using&amp;nbsp;the Compiler" section "HC(S)08 Back End" -&amp;gt; "Calling Protocol and Conventions"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THere is no way to change the calling convention (i.e. The way parameter are passed and values are returned).&lt;/P&gt;&lt;P&gt;When you are mixing C and assembly file it is your responsibility that your assembly files follows the compiler calling convention.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2009 20:14:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175619#M5673</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2009-04-24T20:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: HC908 back end integrating asm+C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175620#M5674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What made you think i did not understand the calling convention ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx anyway, pity that the calling convention &amp;amp; the compiler dont seem to want to know about a condition code...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had the hope that there would be a pragma for it or that RTS ! {},{} could be used.&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by MrBean on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-04-28 13:43&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;01:43 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2009 18:26:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175620#M5674</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2009-04-28T18:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: HC908 back end integrating asm+C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175621#M5675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can submit a service request to ask for an extension in&amp;nbsp;the compiler.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the URL for submitting a service request:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.freescale.com/webapp/servicerequest.create_SR.framework?regFlag=fromOpenSR" rel="nofollow" target="_blank"&gt;https://www.freescale.com/webapp/servicerequest.create_SR.framework?regFlag=fromOpenSR&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2009 19:45:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175621#M5675</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2009-05-06T19:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: HC908 back end integrating asm+C</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175622#M5676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I could, yes.&lt;/P&gt;&lt;P&gt;But that would be just one user asking for a seldom used compiler extention, imho...&lt;/P&gt;&lt;P&gt;I'll do with what i have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been looking at these library functions from rtshc08.c:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
#pragma NO_EXITvoid _PUSH_CC(void) {/* DESC:    push condition code without affecting any other register   IN:      CC   OUT:   WRITTEN:  */   asm {                PSHA                ; // save A                TPA                 ; // save CC on stack                PSHA                LDA    4,SP         ; // push return address                PSHA                LDA    4,SP                PSHA                LDA    4,SP         ; // reload A                RTS ! {H+X+A}, {SR}   }}#pragma NO_EXITvoid _POP_CC(void) {/* DESC:    pop condition code without affecting any other register   IN:   OUT:     CC   WRITTEN:  */   asm {                STA    4,SP        ; // save A                PULA               ; // move return address to the place of '_PUSH_CC'                STA    4,SP                PULA                STA    4,SP                PULA               ; // restore CC                TAP                PULA               ; // restore A                RTS ! {H+X+A+SR}, {}   }}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here the compiler clearly knows about CC aka SR.&lt;/P&gt;&lt;P&gt;Looking at generated code: the compiler uses the above functions quite often.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you (or someone else) explain what these do, please ? :&amp;nbsp;&lt;/P&gt;&lt;P&gt;RTS ! {H+X+A}, {SR}&lt;/P&gt;&lt;P&gt;RTS ! {H+X+A+SR}, {}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been reading the help about "In &amp;amp; Gen Sets" but i still dont understand it quite...&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by MrBean on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-05-12 16:56&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;04:56 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:24:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/HC908-backend-intergrating-asm-C/m-p/175622#M5676</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2020-10-29T09:24:21Z</dc:date>
    </item>
  </channel>
</rss>

