SX/B and array
TransistorToaster
Posts: 149
Hello,
I'm looking for an effcient way to handle a byte array in SX/B. It is not for a lookup table. The goal is to have easily compilable high level code.
Can I replace the below code
array1 var byte(16)
ptr1 var byte
x var byte
i var byte
ptr1 = array1
ptr1=ptr1+i
get ptr1, x
with something like array1 ?
Frank
I'm looking for an effcient way to handle a byte array in SX/B. It is not for a lookup table. The goal is to have easily compilable high level code.
Can I replace the below code
array1 var byte(16)
ptr1 var byte
x var byte
i var byte
ptr1 = array1
ptr1=ptr1+i
get ptr1, x
with something like array1 ?
Frank
Comments
Use the virtual array __RAM() like so:
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
Nice to hear from you again. Is there anything with built in indexing?
N.B. The previous post seems to have lost the index...
>with something like array1(i) ?
Frank
I don't follow what you mean by "Is there anything with built in indexing?".
What exactly is it you want to do ?
Array names are just constants into the __RAM() array. So array1(5) basically gets translated into __RAM(array1+5) by the compiler.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
I've been doing assembly for 10+ years. I agree that the declaration array1 var byte(16) assigns the address of the first element of array1 and that __RAM(array1+5) is absolute addressing, with, as you said, just constants.
I am not looking for indirect addressing , which is pretty much the first piece of code I wrote. (OK, we don't use that term for non-assembly languages)
I'd like to do in SX Basic array1( i), where i is a variable.
In RISC assembly with no absolute indexed support, it should be quite ugly and look like
mov fsr, #i ;2cc pseudo-instruction
mov fsr, ind ;2cc pseudo-instruction
add fsr, #array ;result in IND = array1(i).
Frank
In SX/B you CAN do:
Now if i is a WORD, you'll need to use:
Other than that, keep beating me over the head until you get what you want. I'm a little lost (but it's early, and I haven't had my Mt. Dew yet).
Bean.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·