Shop OBEX P1 Docs P2 Docs Learn Events
BS2p 48/40 (RUN) Command — Parallax Forums

BS2p 48/40 (RUN) Command

Hello All,
My program uses multiple Slots. I do a "RUN" from slot 4 to Slot (7) and when I'm done I do a "RUN 4" with a jump table at the top. OK, it works. But now I want slot (5) to run that same coded in Slot 7. But it is currently FIXED at "RUN 4".
Question:
1) Can "RUN" be set up as a variable? (RUN 'variable').

This way I can do a "PUT" to EEPROM when leaving a Slot and do a "GET" from EEPROM when I have to return to a particular Slot.

Did a help and could not find anything. I don't think the 'POLLMODE' would help me. I currently use a jump table when I return to my Slot. But that's three (3) different launching routines from within one (1) Slot, that works. Will look at setting up different launch table of "RUN" Commands using "IF/THEN".

Thanks for any help

Comments

  • Yes, the argument for RUN can be a variable. And as you suggest, PUT the return slot in SPRAM (not EEPROM!) at a certain address set aside as a one-level "stack". Then in the other slot, GET the value and use it for the RUN.

    My own preference is to break the "stack" byte in SPRAM into two nibs. NIB0 is the target slot for the return, and NIB1 is the index of the location in the target slot that will be used for branching within the slot. Thus, when slot 4 wants to branch from and return to its 3rd code segment, and the target is the 2nd code segment in slot 7, it PUTS $34 in the SPRAM return stack and executes a RUN $27. Once the second code segment in slot 7 finishes, it GETs and then RUNs $34 to return it to slot 4, and there it does BRANCH $3,[.,.,.,address] back to the address of code segment 3. The mechanism uses the same format for both the cross-slot call and for the return.

    The same thing from say the 6th code segment in slot 5. PUT $65, then RUN $27. In slot 7, BRANCH $2,[adrs0,adrs1,adrs2,.,.]. On return GET and RUN $65 and then BRANCH $6,[adrs0,adrs1,.,.,.,.,adrs6].
  • Thanks Tracy,

    I will have to study this and then make it work. Never had to do that before so I'm not clear on what your saying. Will research in the help file so I fully understand what I'm doing. I've got 3 Slots at 97,99,99 % and now I can't modify one of them for "Trouble Shooting". Will have to move that routine out and use your suggestion. Just did a printout to read over. May need some more clarification later on.

    Thanks for now


Sign In or Register to comment.