Variable space BS2p-40
Archiver
Posts: 46,084
Hi everyone,
please can someone help me again!!!
I have run out of variable space in one of the program slots, is it
possible to make more variable space available, preferably without
any loss of program performance?
Thanks again
Jon
please can someone help me again!!!
I have run out of variable space in one of the program slots, is it
possible to make more variable space available, preferably without
any loss of program performance?
Thanks again
Jon
Comments
jonm@p... writes:
> I have run out of variable space in one of the program slots, is it
> possible to make more variable space available, preferably without
>
No, the variable space cannot be expanded. What you CAN do, however, is use
the SPRAM to temporarily save information while you allow a few of your
variables to do double-duty. You can alias the variables so that they have
meaningful names where you apply them.
Use PUT to move data into SPRAM and GET to retrieve it. Keep in mind that
GET and PUT only work with Bytes, so you'll need to use to PUTs and two GETs
with Words. If you have a couple of NIBs to save and retrieve, alias them
into the same Byte so you can do it in one operation.
-- Jon Williams
-- Applications Engineer, Parallax
[noparse][[/noparse]Non-text portions of this message have been removed]
memory, so can swap values in and out of them. Just use PUT to save
variables and then GET when you need them again.
Another related item is to use aliases for your variables. Imagine you have
a variable x and a loop counter y. These are completely unrelated and not
used at the same time. For example in quasi-code:
x var byte
i var byte
top:
x=????
gosub do_stuff_with_x
for i=1 to 100
gosub do_stuff_unrelated_to_x
next
goto top
X doesn't depend on i and i doesn't depend on X. So you could rewrite this
as:
x var byte
i var x ' I is an alias for X
top:
<same as above>
Now you are using 1 byte instead of 2 and your program is still clear and
readable.
You could combine these two techniques to relax the requirements so:
i_save con 0
x_save con 1
x var byte
i var x
put i_save,0 ' i=0
top:
x=????
gosub do_stuff_with_x
put x_save,x
get i_save,i
i=i+1
if i=10 then the_end
put i_save,i
get x_save,x
goto top
Now, this works even though the second technique would not because the value
of i is maintained throughout the loop. Still only one byte and still --
sort of -- readable.
Al Williams
AWC
* Easy RS-232 prototyping: http://www.al-williams.com/awce/rs1.htm
>
Original Message
> From: Jon [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=-lzLFFNIsDowCtanbX_dDVKhYsbTQLn5QrkwAXzzYORF5KXDIGKpaygtpPvG7e5LTuYyn-h6qg]jonm@p...[/url
> Sent: Thursday, August 30, 2001 11:47 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Variable space BS2p-40
>
>
> Hi everyone,
>
> please can someone help me again!!!
>
> I have run out of variable space in one of the program slots, is it
> possible to make more variable space available, preferably without
> any loss of program performance?
>
> Thanks again
>
> Jon
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
> Subject and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>