Re: RTN two levels! Message #3 Posted by Howard Owen on 21 Sept 2011, 7:00 p.m., in response to message #2 by Howard Owen
I'm nested in two levels of self-reply calls. :)
001 42,21,11 LBL A
002 32 1 GSB 1
003 31
004 42,21, 2 LBL 2
005 0 0
006 43,30, 0 TEST 0
007 43 32 RTN
008 6 6
009 16 CHS
010 44 25 STO[I]
011 32 25 GSB[I]
012 42,21, 1 LBL 1
013 22 2 GTO 2
[f][A] then [g][P/R] and see "004 42,21, 2 ".
Single step reveals that this works:
001 42,21,11 LBL A
002 32 1 GSB 1
012 42,21, 1 LBL 1
013 22 2 GTO 2
004 42,21, 2 LBL 2
005 0 0
006 43,30, 0 TEST 0
008 6 6
009 16 CHS
010 44 25 STO[I]
011 32 25 GSB[I]
007 43,30, 0 TEST 0 Incorrect line number - really line 6.)
008 43 32 RTN Really line 7 and it returns to one past the GSB target
instead of one past where GSB was called
007 43 32 RTN Right line#
003 31 R/S Second RTN behaves correctly.
edit: change conclusion. It doesn't pop, it sizzles. :)
Conclusion: You only ever need one RTN instruction in a program! GSB [I] to the line before the RTN. The RTN will execute twice, and you will end up at the proper place for the GSB pending when you called GSB[I].
Bleh - trading RTNs for GSBs. Bet it's a net loss in memory.
Edited: 21 Sept 2011, 7:20 p.m. after one or more responses were posted
|