Problem accessing variables via address between objects
scurrier
Posts: 32
Hello,
I wrote a simple object for making an array 2D. I can't seem to get it to work. I was also having trouble accessing variables by address earlier today in a separate project. Can I get some help?
Here is the object for doing 2d arrays:
Here is the object I am using to test the 2d array object:
And here is the output I get from the serial terminal:
Thank you!
I wrote a simple object for making an array 2D. I can't seem to get it to work. I was also having trouble accessing variables by address earlier today in a separate project. Can I get some help?
Here is the object for doing 2d arrays:
''Array.spin {{Returns the element at position (index1, index2) in an array that has num_index2 elements along the index2 direction }} PUB b ( index1 , index2 , num_index2 , address ) result := byte[@address][index2*num_index2 + index1] PUB wb ( index1 , index2 , num_index2 , address , value ) byte[@address][index2*num_index2 + index1] := value PUB l ( index1 , index2 , num_index2 , address ) result := long[@address][index2*num_index2 + index1] PUB wl ( index1 , index2 , num_index2 , address , value) long[@address][index2*num_index2 + index1] := value
Here is the object I am using to test the 2d array object:
''test.spin CON _xinfreq = 5000000 _clkmode = xtal1 + pll16x VAR byte UseDebug byte testlong[16] OBJ Debug: "FullDuplexSerialPlus" a: "Array" PUB Main | i, i2 UseDebug := 1 if UseDebug Debug.Start(31,30,0,57600) waitcnt(clkfreq*1+cnt) Debug.Tx(Debug#CLS) waitcnt(clkfreq*1+cnt) i:= 0 i2 := 0 a.wb ( i , i2 , 4 , @testlong , i+i2) Debug.Dec(i+i2) Debug.Tx(13) Debug.Dec(a.b(i,i2,4,@testlong)) Debug.Tx(13)
And here is the output I get from the serial terminal:
0 109
Thank you!
Comments