Shop OBEX P1 Docs P2 Docs Learn Events
ram allocation possibilities? — Parallax Forums

ram allocation possibilities?

kelvin jameskelvin james Posts: 531
edited 2005-01-03 19:18 in BASIC Stamp
Just out of curiousity, i was thinking since the variable ram can be allocated to a bit, nib, byte or word, would it be possible to mathematically combine any of those to produce a different size variable? eg. BYTE plus a NIB = a 12 bit variable. I have kinda forotten some of the old hex math and laws involved with it, but it would produce a value range much more useable in my applications than using a full word value( 65536 ). This value would be assigned to a single variable. Seems like a lot of wasted ram to use a word, just to get a number higher than a Byte (256). Hopefully you can understand where i am coming from on this. Don't know if this possible because of the physical structure of the ram or the pbasic software, but it would be nice if i could be done. It would open up a lot of space for more variables in a program. Maybe a dumb question, but was just an idea i thought was worth asking. Thankyou.

kelvin

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-01-03 19:18
    You may not be aware of it, but the math routines for each data type (NIBBLE, BYTE, WORD) are different. They must take into account overflow, carry bits, underflow. Redoing these things for a 12-bit variable would not be trivial.

    Plus, the BS2 only has 26 bytes (13 words) of RAM anyway. You can easily add external EEPROM to store more data, and there does exist a RAM module as well.

    Short answer -- it would be difficult, and it would have very limited applicability, and there are other solutions much easier to implement and more generally useful.
Sign In or Register to comment.