Breaking out of a function properly?
So I decided to try a different approach regarding the code and before I show a few examples of my coding, I want to get back to one bit of 680x coding that has me scratching my head looking for a clean way to rewrite it.
There are seven instances in the code, where the subroutine (or function) is called, and if one conditional is met, it makes a small jump to the return call. If the conditional goes to the "else" case, there are a couple instructions that effectively discard the saved return address, followed by a jump to a completely different program section.
Here's what I mean:
Code:
$FC80 LDA A #$01
STA A $B7
STA A $C9
LDA A #$10
STA A $BE
JSR $F12C
LDA A $B7
BLE $FC96
INS
INS
JMP $EE0A
$FC96 CLR $C9
RTS
So, if address $B7 is less than or equal 0, then it hops forward to the ending instructions of the subroutine / function, while the "else" case is the next instruction.
The two INS instructions nudge the stack pointer to tell the CPU to forget the subroutine it was currently executing and jump off to the code at $EE0A.
How would I approach this in C++ without risking the stack filling up with abandoned subroutine calls? I already have a rough translation ready to shine up into proper C++, it's just the jump that remains, and I can get several functions out of the way once i know the answer.