>So then would these be valid operations using calculus during a mov command. ?
NO, there are no calculations and/or indirect addressing allowed.
You have to change the source or destination pointer by poking around in the instruction itself.
If there for some reason where no outerloop (most of the time there is)
eg this part is only run through once since cognew
you could remove the first 7 lines of code as there is no need to reset the values
and have the compiler give you the first run to start out with (+1 is added at compile and not at runtime)
mov t1,#9 ' loop
lable1 cmps sort+1,sort wc ' c=1 if sort+1 is less than sort
lable2 if_c mov t2,sort ' copy sort to temp
lable3 if_c mov sort,sort+1 ' copy sort+1 to sort
lable4 if_c mov sort+1,t2 ' copy temp to sort+1
add lable1,mybit9_0 ' add 1 to both source and dest field
add lable2,#1 ' add 1 to source field
add lable3,mybit9_0 ' add 1 to both source and dest field
add lable4,mybit9 ' add 1 to dest field
djnz t1,#lable1 ' loop 9 times after that never run this part again
Holy Smile it just clicked I think!
I could not figure out what you were doing with the movs and movd and then the labels. label1 ........ label4. mov destination of that line and then mov source of that line to the operator of the labeled line. Thats slick, I still haven't muddled my way completly through the code, but that is a pretty big piece that I wasn't grasping. Is that what is meant by self mod code?
I am sure you were either yelling at me or laughing at me through your computer. Compile time vrs run-time helps me with the calculus part.
Thanks for the patience.
In running these pieces of code I realize there are many ways to be really efficient in the use of cog RAM:
e.g. moving code into body section of Kuroneko program snippet
Sometimes it gets a bit cryptic and I am far from understanding how to maximize the use of each and every register within a code/data block of cog memory.
Does anyone have an example of extremely (or the most) powerful program(s) ever loaded into a single cog? With 512 longs there has to be a limit but who has reached it and know that they can not pack another bit of functionality within 2K of logic?
There should be some sort of Parallax Hall of Fame for generally acknowledged 'super-cog' examples that the novice can shoot for.
This is probably a ridiculous piece of rhetoric but I am curious.
sm
While it is not easy to read, I think Chip's Spin Interpreter would have to win hands down for the most powerful and full use f the cog space. The code is very convoluted to squeeze everything in!
I have extended the original to sequeeze/hide a zero footprint LMM style trace/debugger into the shadow registers.
It doesn't save much space, but every little bit counts, I am going to jam all of this in Jason's 9DOF object.
I need to figure out how to time sections of code in PASM, I suspect that the latter code is actually faster because there are no DJNZ commands but I am not sure.
I suspect timing the code in PASM probably isn't much different than doing it in spin, I just haven't tried it yet.
This won't work as expected, you need at least one insn between the one modifying and the one being modified (there are exceptions when you expect the resulting behaviour but here it's essential).
Ah, you caught it.
That is why it wasn't working, I just got done playing with it and it was missing my first mov command. I see what you did there I will have to try that real quick.
Nice catch Tony, I see what your saying about resetting the code. The next time I ran through the loop it would have been really messed up.
That would have really screwd with me when I tried to implement it in the 9DOF object.
A quick way in PASM to get 2 values sorted (v1 <= v2):
mov tmp, v1
max v1, v2
min v2, tmp
Don't forget to use mins / maxs if you want to sort signed integers. And a median filter is a great idea over a regular moving average for noisy signal data. It excels at removing shot noise while still preserving hard edges (for things like looking at a square wave...the moving average will delay and soften the edges, while the median filter only delays them).
Comments
And if the above is valid than are these two pieces of code equivalent.
It has been complicated to for me the whole time.
Thanks
NO, there are no calculations and/or indirect addressing allowed.
You have to change the source or destination pointer by poking around in the instruction itself.
If there for some reason where no outerloop (most of the time there is)
eg this part is only run through once since cognew
you could remove the first 7 lines of code as there is no need to reset the values
and have the compiler give you the first run to start out with (+1 is added at compile and not at runtime)
I could not figure out what you were doing with the movs and movd and then the labels. label1 ........ label4. mov destination of that line and then mov source of that line to the operator of the labeled line. Thats slick, I still haven't muddled my way completly through the code, but that is a pretty big piece that I wasn't grasping. Is that what is meant by self mod code?
I am sure you were either yelling at me or laughing at me through your computer. Compile time vrs run-time helps me with the calculus part.
Thanks for the patience.
I have extended the original to sequeeze/hide a zero footprint LMM style trace/debugger into the shadow registers.
From what I have learned I have been able to go from a command like this.
mov sort +[12/3 + 2 * 4^6], temp
which obviously worked in my head, but no where else.
to this
Which moves my running ax array from my accelerometer into my sort array to be sorted.
It replaces this.
It doesn't save much space, but every little bit counts, I am going to jam all of this in Jason's 9DOF object.
I need to figure out how to time sections of code in PASM, I suspect that the latter code is actually faster because there are no DJNZ commands but I am not sure.
I suspect timing the code in PASM probably isn't much different than doing it in spin, I just haven't tried it yet.
Thanks Again
Shawn
That is why it wasn't working, I just got done playing with it and it was missing my first mov command. I see what you did there I will have to try that real quick.
But what about this, it seems to work and saves 2 lines of code?
Setting/Resetting the values before the loop and using 0 (eg 0-0) at intended locations
to show that this code will self modify is the preferred way.
That would have really screwd with me when I tried to implement it in the 9DOF object.
Jonathan