ASM memory acess problem
Kye
Posts: 2,200
Hello all,
I've been having a bit of problems with the rdbyte instruction and using inbedded address when starting a cog process with asm. Basically here is what I'm doing.
~VAR
byte scaling
~PUB setScaling(value)
scaling := value
~PUB driver
scalingAddress := @scaling
cognew(@intialization, $00000000)
~DAT
... More code here
rdbyte buffer, scalingAddress
....More code here
scalingAddress long 0
The set scaling command is not working, I believe that the address of the scaling value is not being passed propely.
The idea is that I embed the address of the varaible in the main memory into the cog when the cog is launched so I can eassily acess the variable without a look table or any type of translation. I have used this approach now with my own homebrew video driver, mouse, and keyboard driver and the method has always worked.
Basically, I know the rdbyte command is the problem in my program, I inserted some mov commands in after to set the value to a test value and the program behaves as it should. I even inserted an address into the scalingAddress variable to grab the first few bytes out of the main memory looking at the image that is created by the complier and the program works as it should.
So what am I doing wrong? I using the same method for wrbyte in the program and everything works fine. But for rdbyte it seems as if the instruction is grabing the wrong variable...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
I've been having a bit of problems with the rdbyte instruction and using inbedded address when starting a cog process with asm. Basically here is what I'm doing.
~VAR
byte scaling
~PUB setScaling(value)
scaling := value
~PUB driver
scalingAddress := @scaling
cognew(@intialization, $00000000)
~DAT
... More code here
rdbyte buffer, scalingAddress
....More code here
scalingAddress long 0
The set scaling command is not working, I believe that the address of the scaling value is not being passed propely.
The idea is that I embed the address of the varaible in the main memory into the cog when the cog is launched so I can eassily acess the variable without a look table or any type of translation. I have used this approach now with my own homebrew video driver, mouse, and keyboard driver and the method has always worked.
Basically, I know the rdbyte command is the problem in my program, I inserted some mov commands in after to set the value to a test value and the program behaves as it should. I even inserted an address into the scalingAddress variable to grab the first few bytes out of the main memory looking at the image that is created by the complier and the program works as it should.
So what am I doing wrong? I using the same method for wrbyte in the program and everything works fine. But for rdbyte it seems as if the instruction is grabing the wrong variable...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Comments
COGNEW(@initialization,@scaling)
then do:
rdbyte buffer,PAR
or
wrbyte buffer,PAR
Its for a mouse driver, actually. I have everything else working perfectly fine except for the ability to change the mouses current scaling during run time.
I'm using a few wrbyte commands using the same techinique, and·they are all working like they should. Its just the rdbyte command that's not working. I think is an addressing problem.
Would it help to know the the scaling byte is the fourth bytes in a series of bytes I made in the main memory?
Also the packet state long starts off uninitalized and usualy contains random data that is transmited or recieved from the mouse.
The idea of this program is that when scaling is equal to $FF the feature turns on and when its equal to $00 the feature turns off.
This section of code is run in a loop.
Anyway, thanks for your help.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Post Edited (Kye) : 12/29/2008 10:16:46 PM GMT
This assumes that the upper three bytes of packetstate are always zero.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
The code you've shown looks okay. I would almost bet that you've got some long definitions in your DAT section after some res definitions, which will cause a loss of sync between cog and hub addressing. Always put your res definitions last.
Did I guess correctly?
-Phil
I tracked the problem all the way up to this part.
I have tried repeated to set the variable to any non zero value and it won't change. I even wrote a method in the object that launches my driver and the value does not change fom zero even after reapeatedly being acessed.
To check all this I tried passing addresses of random bytes in the memory after looking at the complied map and the driver worked as expected.
Whats not expected is that I cannot set the scaling address value to anything other than zero...
I hope its not a problem with the spin compiler or interpreter...but I can't find any other bugs in this code.
The driver interprets anything other than 0 as true and 0 as false so it should be very easy to see results but I cannot.
The bug is somewhere is this piece of code. Everything works except the scaling part...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
-Phil