best way to access variable of an object
Scott Lewis
Posts: 18
I don't know weather to use a get method or pass addresses to access variables modified by some assembly code, so far I can't get the address passing via the start method to work. below is an example of what I mean:
I thought the call to this start method which passed pointers to its own data variables would then be able to access the latest values without a get(index) method, but it doesn't work for some reason.
VAR long data(5] PUB start(dataAddr0,dataAddr1,dataAddr2,dataAddr3,dataAddr4) longmove(@data[noparse][[/noparse]0],@dataAddr0,5) cognew(@entry,@data[noparse][[/noparse]0]) DAT org 0 entry 'assembly code here which modifies data[noparse][[/noparse]] elements
I thought the call to this start method which passed pointers to its own data variables would then be able to access the latest values without a get(index) method, but it doesn't work for some reason.
Comments
And, these a very easy way arround this.
Since asm code just floats arround in the main memory it can be acessed like any other code.
So, you can assign and asm long variable the address of a variable for spin and then launch the processor with all the addresses embeded in it.
Like:
var
stuff [noparse][[/noparse]6]
Pub
adrStuff := @stuff
cognew...
Dat
...
adrStuff long 0
......
Doing it this way is quick and painless.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
If you want to pass several parameter addresses, you could do
first object, declared by 2nd object:
2nd object, declares first object
now in theory, the 2nd object should print out whatever the first object stores in its data variables, but it doesnt. I have verified that it is able to store the variables in main memory and the asm code works by putting the loop to print them out in object1 and removing the parameters to the start() method and loading the code directly. I do not want to use a get(index) method to return the data each time because it needs to be semi-fast.
Post Edited (Scott Lewis) : 2/19/2009 1:08:01 AM GMT