Variable Space & Lookup Table
Welp, I just hit 19 Variables on the SX28·and wanted to add some more functionality.
Referencing the help file on Variables, I'm seeing:
![attachment.php?attachmentid=73947](http://forums.parallax.com/attachment.php?attachmentid=73947)
Looking at my code·I have:
1.· How do I determine how much variable space do I have left?
2.· In the case of aliasing,· shouldn't they function as a regular variable?
When I comple this, I get a 'BYTE VARIABLE EXPECTED: "j"' error.
·3.· Within my program, have a a incrementing counter.·· Based on·that counter, I want to lookup a position for a predefined·address label, and use it in the read statement later on in my programm.
Is there another alternative, to do what I want to do other than multiple if-then's?· Branching won't work since I don't actually want to execute the code at the addresses.
Thanks!
Rodney
·
Referencing the help file on Variables, I'm seeing:
Looking at my code·I have:
- 6 Word Variables = 12 Bytes
- 7 Byte Variables
- 3 element Array of type Byte
- 3 I/O Ports
1.· How do I determine how much variable space do I have left?
Mapping out the remaining space, I was curious·how are I/O ports part of the variable mapping, and how much actual variable space I have left:
It looks like I have the following available:
It looks like I have the following available:
- 1X5
- 1X1 (using 3 elements of the 1X4)
- 6X16· > Is this·where the max 16 comes from in the table?
2.· In the case of aliasing,· shouldn't they function as a regular variable?
myValue Word index VAR byte(3) i VAR index(0) j VAR index(1) k VAR index(2) j = 3 Lookup j, CON1, CON2, CON3, CON4, CON5, CON6, myValue
When I comple this, I get a 'BYTE VARIABLE EXPECTED: "j"' error.
·3.· Within my program, have a a incrementing counter.·· Based on·that counter, I want to lookup a position for a predefined·address label, and use it in the read statement later on in my programm.
I initially tried·using the WDATA statement, as in
WDATA LABEL1, LABEL2, LABEL3, LABEL4, LABEL5
The compiler didn't like it.· Should this work?
In finding an alternative, I used a real byte instead of an array, on #2 above,
The compiler liked it better, but still complains with the following:
In finding an alternative, I used a real byte instead of an array, on #2 above,
myValue VAR Word i VAR Byte i = 3 LOOKUP i, LABEL1, LABEL2, LABEL3, LABEL4, LABEL5, myValue
The compiler liked it better, but still complains with the following:
·Warning 73, Pass 2: Mulit-byte instruction following skip instruction.·
Looking at the assembly shows that it looks like it's doing what I want.· Is there any concern?
Looking at the assembly shows that it looks like it's doing what I want.· Is there any concern?
Is there another alternative, to do what I want to do other than multiple if-then's?· Branching won't work since I don't actually want to execute the code at the addresses.
Thanks!
Rodney
·
Comments
1) I/O port pins don't count as variables at all. The SX28 RAM is broken into 16 byte "banks". These "banks" are NOT continuous. So an array cannot extend from one "bank" to the next". So if you were to·declare arrays of 9 bytes, the 7th one would fail. In short ALWAYS declare arrays largest first, smallest last.
2) Yes, many commands will work with aliased array elements. LOOKUP and LOOKDOWN are two that do NOT support array elements YET (hint hint). There are some others too, for instance an array element cannot be used as a FOR-NEXT control variable.
3) Rodney, you always seem to think of things I never have. I would have never guessed that someone would want to put labels in a WDATA command. For now, I would use the multiple IF-THEN statement. I'll look into allowing this.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
There are only two guaranteed ways to become weathy.
Spend less than you make.
Make more than you spend.
·
I made a SX/B library file of my assembly routines.
These let you read/write both ram and the special config registers
and also allow rambank0 access, all via SX/B.
The file with extension LB (for Library Basic) is 'load'ed into the main SX/B program.
It contains the library·subroutines.
regards peter
Post Edited (Peter Verkaik) : 10/1/2006 4:50:42 PM GMT
Lists of Lists
It just seemed logical to me to organize data statements with variable information this way in my application.
For example:
This is kinda like a multidimentional array of constants.· If the user selects 1, they will access the data from list1; 2, for list2, etc.
Still not clear on Avail. ROM/RAM Space:
Peter, thanks so much for the files.··I was a little dissapointed that·I'd be two variables short when I go to the SX/48 board, and was affraid my app may not have the flexibility I initiall desired on the SX/28,·but now I have renewed enthusiam, once again!· I'm still working on·enhancing what I'm doing, but as soon as I need that one·extra variable, that I can't use w/ an array alias,·I'll be sure to dig in!
Rodney
Post Edited (Yendor) : 10/2/2006 4:08:31 AM GMT