|
Post by Pinacolada on Oct 11, 2008 1:19:35 GMT -5
I know it's ugly, but I'm working on a program in BASIC where I need to POP the last GOSUB off the stack. I've tried kludges like setting flags to designate GOTO vs RETURN, but I think POP would be better.
I've tried Googling comp.sys.cbm, no luck.
Assembly preferred, mainly so I can study and learn?
Edit: I know where the stack is, there is a value which says "Here is a GOSUB" and four more bytes after that. My assumption is that you would PLA stuff from the stack including and after that byte.
Is there a stack depth byte which needs to be decremented, too?
Edit: TSX and TXS opcodes exist, okay, hmm...
|
|
|
Post by Pinacolada on Nov 19, 2008 19:00:43 GMT -5
Got this answered by xlar54. Thanks. 
|
|
|
Post by Robin Harbron on Nov 19, 2008 19:39:59 GMT -5
Got this answered by xlar54. Thanks.  Can you share with us here? I looked into this briefly, but couldn't find a good answer. I wasn't sure if there was more to it than just clearing the info off the 6502's stack (like, if BASIC kept other related info elsewhere).
|
|
|
Post by Pinacolada on Nov 21, 2008 2:34:43 GMT -5
Here is the disassembly. Can't tell you much about it, don't understand a whole lot. I'll try to study later. .C:02a7 68 PLA .C:02a8 68 PLA .C:02a9 A9 FF LDA #$FF .C:02ab 85 4A STA $4A .C:02ad 20 8A A3 JSR $A38A .C:02b0 9A TXS .C:02b1 C9 CMP #$ .C:02b3 F0 03 BEQ $02B8 .C:02b5 4C E0 A8 JMP $A8E0 .C:02b8 68 PLA .C:02b9 68 PLA .C:02ba 68 PLA .C:02bb 68 PLA .C:02bc 68 PLA .C:02bd 60 RTS
|
|