Self-modifying code question - one way works t'other doesn't!
Alex Mackinnon
Posts: 25
Hi,
In my ASM this works...
······· mov vv2,#table
······· add vv2,idx
······· movs :rdtab,vv2
:rdtab··mov vv1,#0
...etc,·······
but this does not...
······· movs :rdtab,#table
······· add :rdtab,idx
:rdtab··mov vv1,#0
...etc,
...and I think it should! The second would potentially save 2 longs (1 instruction and 1 temporary register)
Thanks,
A.
In my ASM this works...
······· mov vv2,#table
······· add vv2,idx
······· movs :rdtab,vv2
:rdtab··mov vv1,#0
...etc,·······
but this does not...
······· movs :rdtab,#table
······· add :rdtab,idx
:rdtab··mov vv1,#0
...etc,
...and I think it should! The second would potentially save 2 longs (1 instruction and 1 temporary register)
Thanks,
A.
Comments
I'm really just still playing at the moment... getting the feel of the best way to use the assembly and the cogs - for instance I've just spotted that I could do away with the regi table and just shift the idx value by 12-bits for the same effect. Like I say - just playing to see how it all works - although I've got 6-axis with quadrature feedback, jog-buttons, VGA display, keyboard, G&M code interpreter and programme editor all in 24K at the moment LOL.
Post Edited (Alex Mackinnon) : 5/23/2007 2:37:08 PM GMT
You are correct that the information is lacking from our literature, however that information belongs in the manual when discussing MOVS/MOVD/MOVI since no in depth discussion of the instructions occurs in the datasheet. I will get the information added to the errata. Meanwhile you should check out the Propeller Tricks and Traps sticky thread, it has the information about the self-modifing instructions plus a whole slew of other gotchas you may not be aware of.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
I'll download the tips and tricks too.
My gripe about the parsity of the data is no detraction from the processor though [noparse]:)[/noparse]
You're correct; a T-state diagram is just the sort of thing which belongs in the datasheet. I have added it to the to-do list for the datasheet. For your current edification, the Pipeline is SDIR (Source Destination Instruction Result) where the instruction stage is for the next executed instruction (this is also the execute stage for the current instruction), but it is this interleaving of the instruction fetch and result which dictates the need for an intervening instruction when doing self-modifying code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
loop ADD plot, d1
plot WAITVID lineram, #%%3210
DJNZ count, #loop
So the first time through the loop, it's WAITVID lineram, and the second time it's lineram+1.
So, instead of a NOP, one puts a useful instruction between the modifier, in self modifying code, and the target of the modifier. The target instruction is conditional, with the flag condition being set in the instruction immediately prior to it.