![]() |
coldfire assembly - rts causes Illegal Instruction Exception
Hi all, I've been trying to fix an illegal exception for a couple of hours now with no success.
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: Caller: :
process_input |
I'm not familiar with that particular assembler, but I doubt it differes from most in this respect: one CALLS a subroutine, then returns. Branching to a subroutine transfers control without recording a return address on the stack. The return instruction then just loads whatever junk was on the stack into the IP and off you go into the weeds, barfing all the way. On the other hand, when you call, the current IP is put onto the stack before the branch is made, and is there for the return instruction. Again, I don't know your particular assembler, but I'll shit in my flat hat if it's all that different.
|
Quote:
This is not an issue in this case. When "branching" to a subroutine, (Beq in my case) coldfire saves PC on the stack, and then increments PC by the displacement needed to get to the branch location. |
Quote:
Actually my reply to you is complete garbage. You are absolutely right. When I read your comments late in the AM's I was quick to dismiss it because my brain was not functioning anymore. What I was using was indeed a conditional branch Bcc and what I actually wanted to do was branch to a subroutine. Which by backwards rationalization was what I did hence I replied by saying Pc is indeed saved on the stack. Ah, stories, a good night's sleep and I'm back in business. Thanks for replying. |
You're entirely welcome. I couldn't pursue it in view of my non-familiarity with the particular assembler, it just seemed reasonable.
|
| All times are GMT -5. The time now is 8:03 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC