Author Topic: 9S08 micro - is RSP then exit subroutine okay?  (Read 946 times)

0 Members and 1 Guest are viewing this topic.

Offline CirclotronTopic starter

  • Super Contributor
  • ***
  • Posts: 3375
  • Country: au
9S08 micro - is RSP then exit subroutine okay?
« on: February 02, 2025, 09:34:27 pm »
I have a program where during a sub I check for a number of error conditions. If I find an error I want to exit the sub and JMP to an error handling routine instead of RTS and simply continuing on. Is RSP then JMP to whatever okay? The error handler would look after stuff I had set up manually, but besides the stack pointer being reset, are there other things I should be aware of? Written in assembly. I wouldn’t call myself a programmer.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6482
  • Country: de
Re: 9S08 micro - is RSP then exit subroutine okay?
« Reply #1 on: February 03, 2025, 08:40:15 pm »
RSP is unsuitable for this, it's an initialization instruction, don't mess with the stack pointer unless other solution is impossible.
I'd probably rather execute an SWI to land in the error correction routine and return with an RTI.
But perhaps I'm misunderstanding your need.
 

Offline grumpydoc

  • Super Contributor
  • ***
  • Posts: 2952
  • Country: gb
Re: 9S08 micro - is RSP then exit subroutine okay?
« Reply #2 on: February 05, 2025, 09:42:49 pm »
Depends where you want to go after handling the error.

RSP stuffs 0xFF in the low byte of the stack pointer, it doesn't do anything else like setting the interrupt mask, so if wiping out the call stack and (say) returning to the start of your main loop is what you want to do after dealing with the error then it might well be OK to issue an RSP.

I think that's within the range of things which are plausible in the general case but as it's your code only you can say.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf