Shop OBEX P1 Docs P2 Docs Learn Events
BS1 Memory organization for dummies. — Parallax Forums

BS1 Memory organization for dummies.

yurightyuright Posts: 13
edited 2011-07-04 12:39 in BASIC Stamp
I am new to Basic Stamp and programming. I have been working with the BS2 for a few weeks with great success I decided to get a BS1 and try programming it as well. In reading the BS1 manual I have found I have ZERO understanding of the most basic aspects of memory organization and manipulation. I have searched around for a simple tutorial but haven't found one so far. If anyone knows where I could find this kind of information please post it. thanks

Comments

  • ercoerco Posts: 20,256
    edited 2011-07-03 16:53
    Have you seen the FAQs? http://www.parallax.com/dl/docs/prod/stamps/BasicStampFAQ.pdf

    The BS1 is programmed in PBasic 1 instead of 2 or 2.5, so there are numerous differences to be aware of. But it's a solid performer if you can use all 256 bytes of memory!
  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-03 20:32
    In addition, the Basic Stamp Syntax and Reference Manual (included in the Stamp Editor's help files or downloadable from Parallax) shows how memory is organized in the BS1 in the section on Memory Architecture.
  • yurightyuright Posts: 13
    edited 2011-07-04 11:40
    Thanks for the info, I read the FAQ's which helped a little. I have read the section on architecture in the Syntax Ref Manual. One of the things that has confused me is that with BS1 I guess you have to assign an address for the variables and constants that you create and that the address is chosen based on size needed to accommodate the data. In BS2 you simply create a variable or constant name it and state the size you want for it and the addressing is done for you. If this is the case then am I correct to assume that in BS1 a programmer could potentially use the same address twice and cause problems in the program? One more thing, is there an accepted protocol one would follow in organizing information in the memory? Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-04 12:39
    The BS2 actually works the same way the BS1 does. There are more variables in the BS2 and the compiler will automatically allocate new variable names from the existing variables (B0-B25 or W0-W12).

    Yes, the programmer can re-use the variables under different names. This is useful when combining existing pieces of code that use different names, but sometimes can get you into trouble. The different pieces of code can't leave values in the variables or assume that they'll be untouched later. Anyway, it's a useful tool.

    On the BS2, people generally let the compiler allocate the variables or they explicitly allocate the variables themselves (by declaring a variable to be the same as, say, B1). You are likely to get into trouble if you mix the two schemes.
Sign In or Register to comment.