November 22, 2024, 08:34:02 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Understanding Variables and RAM Organization

Started by Tim-M, January 24, 2008, 08:03:50 AM

Previous topic - Next topic

Tim-M

Within the program editor help, there is a section under PBASIC Reference called 'Memory Organization and Variables'.  I'm having trouble understanding the information that is shown there.

I have a program that uses three varables that I've assigned to B2, B3, and B4.  The values for these varables are simply the digits 0-2.  The program works well and all is good.  What leaves me unsettled though, is that I cannot seem to decipher from the help section, just what values the B variables could be used for?  Help shows that a B variable value can be from 0-255, but what about a text string for example?

Can anyone point me to another document that may help me understand this better?

I'm sure this is a case of my head being mostly solid bone with little room for gray-matter, but I'd feel so much better if I understood this any more than I do now.

Thanks,

Tim

JonnyMac

All computing machines have variable types.  In the BASIC Stamp 1, the "B" variables are byte (8-bit) variables -- byte variables can hold values between 0 and 255.  So, B0 is a byte at index 0 (since we start counting from 0, it's the first); B1 is a byte at index 1, etc.  There are also W (word, 16-bit) variables; words can hold values between 0 and 65,535.  Now, what's really important to understand is that W0 overlays the memory used by B0 and B1.

I wrote an article for Nuts and Volts that should be helpful.  Give this a read and see if it clears things for you:
-- http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv30.pdf
Jon McPhalen
EFX-TEK Hollywood Office

Tim-M

Thanks for your help Jon, I'll read the article and see what I can sort out.

Much appreciated,

Tim