Shop OBEX P1 Docs P2 Docs Learn Events
var byte or var word? — Parallax Forums

var byte or var word?

ArchiverArchiver Posts: 46,084
edited 2000-05-17 11:09 in General Discussion
I got a questions, I been playing with my stamps on and off so I still
having a bit of trouble programing them, any way my question is on the var
command what is the diffrence between byte and word.
For example...
'Start example program
good var word
night var byte
etc...
'End example program
What is the diffrence?
Any info on this would help and yes i do have a manual (2 to be precise).

Chris Shuster
http://www.uhpage.com/cpuman
http://www.geocities.com/cpuman3

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-05-14 15:38
    Say n is byte or nib

    nib will only allow you to do a loop upto 15 if n is a nib

    and upto 255 if n is a byte so with a word you can go to a higher number

    nib is 4 byte is 8 and word is 16

    Dan
  • ArchiverArchiver Posts: 46,084
    edited 2000-05-17 11:09
    Hi Chris,
    With the var command a certain space of the RAM gets allocated to
    that variable.
    If the var is given the size bit there are only 2 values that
    variable can have, 0 or 1.
    If the var is a nib (a nibble) the space allocated is 4 bits and you
    have 2^4 or 16 values (0 to 15)
    If the var is a byte the allocated space is 8 bits, giving 2^8 or 256
    values (numbers 0 to 255)
    If the variable is word, then you allocate 16 bits to that variable,
    giving 2^16 or 65536 values (0 to 65535)

    If your value of the variable "good" is in the range 0 to 255 you can
    use both byte or word, but would be wasting RAM by using the word
    alternative.
    However you cannot use the nib alternative as its maximum is 15.

    Hope that helps,
    Regards,
    Hans

    --- In basicstamps@egroups.com, "Chris Shuster" <cpuman3@h...> wrote:
    > I got a questions, I been playing with my stamps on and off so I
    still
    > having a bit of trouble programing them, any way my question is on
    the var
    > command what is the diffrence between byte and word.
    > For example...
    > 'Start example program
    > good var word
    > night var byte
    > etc...
    > 'End example program
    > What is the diffrence?
    > Any info on this would help and yes i do have a manual (2 to be
    precise).
    >
    > Chris Shuster
    > http://www.uhpage.com/cpuman
    > http://www.geocities.com/cpuman3
    >
    >
    ______________________________________________________________________
    __
    > Get Your Private, Free E-mail from MSN Hotmail at
    http://www.hotmail.com
Sign In or Register to comment.