Marius Posted January 6, 2011 Share Posted January 6, 2011 I'm writing a tool (almost ready) ... and the user can abort a certain process by pressing START (hehe, that makes sense... press START to quit hehehe, but ok) But this 'press start' routine is called IN an existing JSR - RTS loop. So the QUIT routine can not end with an RTS... I created a trick for this PLA PLA RTS Is that a bad solution? Or is this rather common? Any other ideas? Thanks Marius Quote Link to comment Share on other sites More sharing options...
Bryan Posted January 6, 2011 Share Posted January 6, 2011 (edited) If you PLA,PLA you'll remove the first return address and then RTS to the previous address on the stack. If there isn't one, you'll crash. I assume you can't just RTS normally but with some flag set to indicate that START was pressed? Here's a little example (the three dots are where your surrounding opcodes would be): ; The calling routine... ... ... jsr ROUTINE1 bcc continue jmp STARTPRESSED continue ... ... ;called routine ROUTINE1 ... ... lda COLSOL and #01 bne no_start sec ;flag START pressed rts ;immediate exit no_start ... ... ... ;keep processing ... ... clc ;flag START not pressed rts ;normal exit Edited January 6, 2011 by Bryan Quote Link to comment Share on other sites More sharing options...
Marius Posted January 6, 2011 Author Share Posted January 6, 2011 If you PLA,PLA you'll remove the first return address and then RTS to the previous address on the stack. If there isn't one, you'll crash. I assume you can't just RTS normally but with some flag set to indicate that START was pressed? That is an option indeed. But... there will definately be a return adress on the stack, since this "exit" routine (with the pla pla) is always called from a jsr-rts loop. When I get you right, you say: set a flag when the START button is presst. And JMP to the EXIT routine BEFORE the JSR-RTS loop is called again. That is the safest indeed. I'll think it over! Thanks Marius 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.