Grevle Posted July 11, 2020 Share Posted July 11, 2020 How to cancel a RTS instruction in assembler ?. In a JSR loop when you want to break out of the loop with a jmp and need to cancel the jsr stored return adress , Just do a simple PLA ? or CLC ? Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted July 11, 2020 Share Posted July 11, 2020 Two PLAs in a row will remove the return address from the stack. 2 Quote Link to comment Share on other sites More sharing options...
Grevle Posted July 11, 2020 Author Share Posted July 11, 2020 Thanks, i should have know that by now but i been away from programming for quite some time.. Quote Link to comment Share on other sites More sharing options...
ivop Posted July 11, 2020 Share Posted July 11, 2020 (edited) This feature can also be used as tail call optimization. If your subroutine ends with: jsr some_routine rts you can optimize it to: jmp some_routine That's valid for every point where your subroutine ends. So: beq zero bmi minus jsr do_plus rts minus jsr do_minus rts zero jsr do_zero rts equals: beq zero bmi minus jmp do_plus minus jmp do_minus zero jmp do_zero Edited July 11, 2020 by ivop 4 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.