Shop OBEX P1 Docs P2 Docs Learn Events
BS2p40 variable space — Parallax Forums

BS2p40 variable space

LloydsLloyds Posts: 75
edited 2010-05-09 07:44 in BASIC Stamp
Hi,
I'm running out of variable space with the BS2 also. I've tried using constants and am careful with the size argument, but still, I'm barely squeaking by. I've fiddled with the size argument and have been able to bounce between Ok and not enough space.
I'm considering going to the BS2p40. I could make use of the 16 extra I/O pins but am confused about the availability of the extra RAM.

Page 82/83 of the Syntax manual shows 32 total bytes of Ram in the BS2, with 26 that I can use for variables. It says the p40 has 38 total bytes, so does that mean I'd have 6 more bytes for variables? But on the comparison charts, it looks like the 6 extra bytes are for pin assignments for the extra 16 pins only.

Bottom line... is it possible to get more variable space with any of the BS2 family?

Thanks,
Lloyd

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-05-08 16:43
    All of the Stamps have exactly the same amount of variable space, 26 bytes. The BS2p models have what's called scratchpad RAM which is a completely separate area of RAM, accessed with the GET / PUT statements (only). You can't add more. You can add external memory, but that can't be used for variables.

    Typically people use the same variables in different parts of their programs using what's called an "alias" to make the naming more sensible. You can have several different names for the same variables. You can also have one name for a word and two other names for the two bytes of the word. You can have 4-bit variables (nib) and named bits when the values to be used will fit in the smaller space. All of this can help, but you're still limited by the 13 word (26 byte) limit.

    If your application really can't be fit into this constraint, you may have to move to something like the Propeller which has much more space available although it's programmed differently.
  • LloydsLloyds Posts: 75
    edited 2010-05-08 17:42
    Mike,
    Thanks for the info. I read about the aliases and size, and also about modifiers like HIGHBYTE AND LOWBYTE. Sounds like I just need to experiment and find some solutions.
    But I am now wondering about modifiers. If I define a new variable that is made using a modifier on a previous larger variable, does the new variable occupy its own new variable space, or does it use the same space as the original variable? In other words, does using modifiers allow you to cheat and get extra variables without using more RAM?
    Thanks,
    Lloyd
  • Mike GreenMike Green Posts: 23,101
    edited 2010-05-08 17:56
    The modifiers are like aliases. They just provide a different way to reference the same variable. That can sometimes provide extra space as when you have a byte variable used in one section of the program, unused in some other section of the program where you need a NIB value and a couple of BIT values. You can use aliases or modifiers to reuse the byte variable in a different way in the other part of the program.
  • LloydsLloyds Posts: 75
    edited 2010-05-08 18:03
    Mike,
    Got it. This gives me some options to try.
    Thanks,
    Lloyd
  • MoskogMoskog Posts: 554
    edited 2010-05-09 07:44
    You might also take a look at multislot Stamps like the BS2pe. They are more like 8 individual Stamps sharing the same in- or output pins and also sharing SP-RAM, (128 Bytes in this case) You·can go from one slot to another using the RUN-command and save variable values in the SP-RAM until you are back again in the originally slot. Each slot can contain its own program and variables. I think you will find lots of useful information in the BASIC Stamp Syntax and Reference Manual.

    The BS2pe is my favourite Stamp!
Sign In or Register to comment.