Shop OBEX P1 Docs P2 Docs Learn Events
Best way to utilise BS2e program memory? — Parallax Forums

Best way to utilise BS2e program memory?

BullwinkleBullwinkle Posts: 101
edited 2006-11-05 05:30 in BASIC Stamp
I have recently voyaged into the strange and wonderfully weird memory architecture of the BS2e, since my program is just to big for the humble BS2.

Does anybody have an elegant approach on how best to utilise the 8 program slots? I was initially hoping I could use the subroutine stack to do a called to a surrogate routine in SLOT 0, which then did a RUN x to switch to another program, execute some function then RUN 0. Once back in slot 0 I was hoping the subroutine stack was still intact so a RETURN would place me back to the line immediately after the surrogate routine call.

But it seems the stack is destroyed during a program slot switch. Bummer. confused.gif

I initially wanted to break my program into functional components or even layers, but this just doesn't fit with the memory architecture. I cannot, at least easily, call from one program to a subroutine in another.

The only approach which seems to work in my head is to break the program in 8 modules. Each one looks after every aspect of one particular thing, such as running the LCD. All support routines are loaded into the same slot so no cross program calls are ever needed. The slot 0 program then becomes some kind of scheduler that transfers control to a particular slot based on some kind of state variable. The state variable changes depending on events that effect the program, such as button pushes, time changing etc...

More thinking required... smhair.gif

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-05 01:35
    Bullwinkle,
    ·
    ·· Have you read the following Nuts & Volts Article on Multi-Bank Programming?· It might give you some help.· Take care.

    http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • BullwinkleBullwinkle Posts: 101
    edited 2006-11-05 04:21
    Thanks Chris,

    That looks like a great article, and a good way to manage memory on the BS2e. You certainly have to plan this stuff a lot more closely, that's for sure.

    Steve

    aka Bullwinkle
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-05 05:30
    Bullwinkle,
    ·
    ·· That is correct…For Multi-Bank programming you should really plan your program around it.· Trying to convert your program to work with multiple slots can be difficult if the program was not written in a modular fashion.· Three tips I always share with customers wanting/needing to use multiple slots.
    ·
    1)····· Copy all your variable declarations into each program for each slot exactly the same way.· That way your variables will all be preserved when switching slots.· I don’t think that article mentions that.
    2)····· Copy any common subroutines into the other slots since you cannot call them across slots.
    3)····· It is possible to make a variable (NIB perhaps) which can assist you in getting to specific sections of another slot.· For example, if you put a BRANCH command as the first executable instruction (past all variable/constant declarations) then you can cause a jump to a specific label within that slot by setting a variable prior to calling the slot.
    ·
    If you need specific help on doing that let me know and I will post how it’s done.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.