Hmm, Taxing my memory, ouch!
Like most of what I know, it comes from trying to solve other peoples problems.
As I recall, someone was trying to do the same thing by using a variable inside the parenthesis.
Something like this...
Code:
A VAR BYTE[64]
B var Byte
B = 32
HSEROUT [STR A(B)\32]
It compiles just fine, but sure doesn't give the expected results.
After searching through the macro files, It soon became apparent that array notation is handled differently, depending on whether a variable or a constant is used.
If it's a variable, It takes the "Contents" of the array location and uses that as the address of the starting point of the data to send. (even if it's not an array)
If it's a constant, It uses the constant as an offset into the array and uses that location as the starting point. (the expected result)
This same behavior can be seen in other places too.
Let's say you had stored a sequence of A/D ports in an array...
Code:
A VAR BYTE[7] ; [5,7,1,0,2,3,4]
B = 3
ADCIN A(B), ADval ; reads AN0
ADCIN A(3), ADval ; attempts to read AN36 (depending on the location of var A)
; obviously that won't work
Calling meLabs, probably wouldn't have revealed that info.
.
Bookmarks