I am bit confused on when to use rts.
For example, when I jump to a subroutine - jsr, it is clear that rts has to be used.
But when I branch, say bra xxxx or bhi xxxx, can i still use rts?
you can only use RTS when you've called a subroutine, because RTS pulls the return adress from the stack ang continues execution on that adress..
The only branch that calls a subroutine is BSR. Every other branch is just like a jump. So if you use RTS,without a JSR or BSR, you pull two bytes from the stack and return to that adress. This will make your program go crazy.
Of course you can branch and push a return adress on the stack and then use RTS but this is more a theoretical approach.
Hityou123, did this clarify your view on RTS?
Retrieving data ...