<?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>ColdFire/68K Microcontrollers and ProcessorsのトピックRe: Illegal instruction exception generated when executing rts</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Illegal-instruction-exception-generated-when-executing-rts/m-p/139982#M2258</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks for answering. This post was truly an epiphany. I'm saying this because after 6+ hours of not understanding why my code crashes, late in the AMs, someone had replied with a similar explanation on another forum. But since my brain was already turned off, I was quick to dismiss it because, I didn't notice that although what I wanted to do is call a subroutine, what I had actually done is just do a conditional jump. After a couple of hours of sleep...my brain is back in business.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Jun 2006 00:36:07 GMT</pubDate>
    <dc:creator>NOPz</dc:creator>
    <dc:date>2006-06-19T00:36:07Z</dc:date>
    <item>
      <title>Illegal instruction exception generated when executing rts</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Illegal-instruction-exception-generated-when-executing-rts/m-p/139980#M2256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all, I've been trying to fix an illegal exception for a couple of hours now with no success.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What happens is that I have a piece of code that checks for imputs and branches to appropriate subroutine. But after the subroutine finishes when executing the RTS to return to the called throws an Illegal exception. The address in PC seems to be 00000000 which is complete garbage. At the same time I did check my stack manipulation and it looks fine to me. The code snip:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Caller:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;process_input&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; move.l A0, -(A7)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; move.l D0, -(A7)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; clr D0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; lea BUFFER, A0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; move.b (A0), D0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; cmpi.l #$31, D0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; beq return_to_monitor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; cmpi.l #$32, D0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; beq calculator_mode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; cmpi.l #$33, D0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; beq clock_mode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; cmpi.l #$34, D0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; beq clock_display&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; move.l (A7)+, D0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; move.l (A7)+, A0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; rts&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Called sub:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;clock_mode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; move.l A1, -(A7)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; lea ERROR_OPTION_UNAVAILABLE, A1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; bsr.w out_string&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; move.l (A7)+, A1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; rts&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This final RTS instruction generates (snip of trace):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PC: 1020010A SR: A704 [T.Sm.111...xnZvc]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An: 10220000 00000000 00000000 00000000 00000000 00000000 00000000 1023FFEC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dn: 00000033 00000000 00000000 00000000 00000000 00000000 00000000 00000000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1020010A: 4E75 RTS&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;trace&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PC: 00000000 SR: A704 [T.Sm.111...xnZvc]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An: 10220000 00000000 00000000 00000000 00000000 00000000 00000000 1023FFF0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dn: 00000033 00000000 00000000 00000000 00000000 00000000 00000000 00000000&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;trace&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PC: 00000000 SR: A704 [T.Sm.111...xnZvc]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An: 10220000 00000000 00000000 00000000 00000000 00000000 00000000 1023FFF0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dn: 00000033 00000000 00000000 00000000 00000000 00000000 00000000 00000000&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Exception:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Illegal Instruction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; format: 0x04 fault status: 0x0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; vector: 0x04 status reg: 0xA704&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do not know how to approach this, I'm thinking maybe the stack is broken, but I checked my pushes and pops and they match. What causes this exception to arise when executing an rts?&lt;/SPAN&gt;&lt;P&gt;Message Edited by NOPz on &lt;SPAN class="date_text"&gt;2006-06-17&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;08:48 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Message Edited by NOPz on &lt;SPAN class="date_text"&gt;2006-06-17&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;08:49 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Jun 2006 08:46:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Illegal-instruction-exception-generated-when-executing-rts/m-p/139980#M2256</guid>
      <dc:creator>NOPz</dc:creator>
      <dc:date>2006-06-18T08:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Illegal instruction exception generated when executing rts</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Illegal-instruction-exception-generated-when-executing-rts/m-p/139981#M2257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I may be off base, as I haven't used the ColdFire before.&lt;BR /&gt;&lt;BR /&gt;But those look like branch instructions to your subroutines, not call instructions. In other words, I don't believe there is a return address on the stack for the RTS to return to.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 18 Jun 2006 14:12:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Illegal-instruction-exception-generated-when-executing-rts/m-p/139981#M2257</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-06-18T14:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Illegal instruction exception generated when executing rts</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Illegal-instruction-exception-generated-when-executing-rts/m-p/139982#M2258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks for answering. This post was truly an epiphany. I'm saying this because after 6+ hours of not understanding why my code crashes, late in the AMs, someone had replied with a similar explanation on another forum. But since my brain was already turned off, I was quick to dismiss it because, I didn't notice that although what I wanted to do is call a subroutine, what I had actually done is just do a conditional jump. After a couple of hours of sleep...my brain is back in business.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jun 2006 00:36:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Illegal-instruction-exception-generated-when-executing-rts/m-p/139982#M2258</guid>
      <dc:creator>NOPz</dc:creator>
      <dc:date>2006-06-19T00:36:07Z</dc:date>
    </item>
  </channel>
</rss>

