Self modifing code mysteriies
RS_Jim
Posts: 1,768
Hi,
I am trying to write a routine in PASM where i want to replace one variable with another and it does not appear to be working correctly.
any suggestions?
RS_Jim
.
.
I am trying to write a routine in PASM where i want to replace one variable with another and it does not appear to be working correctly.
call sensor 'sensor returns x,y vars cmp x,y wc ' compare results from two sensor inputs if_c replace y with new 'if y is greater next call returns new with y results if_nc replace x with new ' if x is greater next call returns new with x results ... ... ... test cmp old,new wc I have tried: if_c movs #test,#x if_nc movs #test,#ythat doesn't seem to work,
any suggestions?
RS_Jim
.
.
Comments
I'm not sure if your "..." represents more statements or not...
RS_Jim
you are correct, I should have attached actual code, was just not on computer with the code. Here is the troublesome code.
Msic_timer1_test1 - Archive [Date 2011.03.03 Time 07.08].zip
Thanks for the help
RS_Jim
Actually it's worse than that. That writes the value stored in tmp1 to the HUB RAM address equivalent to the register index of rawy. (The way I remember is RD/WRLONG clkfreq,#0 retrieves the current value of CLKFREQ, which is stored at LONG[0].)
In regard to the wrlong tmp1,#rawy step which should be with wrlong tmp1,tlmpntr not #rawy,I was only looking to see what was going to be written in the movd instruction. After dbug, that goes away. My purpose that I should have explained in an earlier post, is to take a vertically mounted MD2125 and use it to measure a slow oscillation. The selfmodifing code was to calibrate which axis of the 2125 is going to be affected by the oscillation. I could eliminate that step and just force the use of one of the axis of the chip and force the chips orentation in the final device. I was using the state steps to determin when the md2125 changed direction at one end of the cycle. Forcing the orentation eleminates one counter and one pin from the final device.
RS_Jim
So the relevant code is as follows: Is that the code you're concerned about? This code should work fine once you remove the debug code that could be causing some problems. The only concern would be that you are not performing a "shr newacc, #4". If the shift right is important you should add that to your code.
Dave
I have not had a chance to get back to the code. I thought that I had gotten the SHR newacc into the code before the return. I will delete the debug code and try it again.
RS_Jim