Shop OBEX P1 Docs P2 Docs Learn Events
prefetch makes MOVD not work for next instruction — Parallax Forums

prefetch makes MOVD not work for next instruction

EricREricR Posts: 35
edited 2008-04-01 12:11 in Propeller 1
I find that I cannot use MOVD to modify the next instruction in code immediately.· I suspect the next instruction is being prefetched, thus delaying the affect of MOVD.· If I target MOVD to the following instruction, the MOVD works as I wanted.

code:
· looptop
············· ...
············· movd Writer, DiagCogAddr ' place the desination address that we·want in the wrlong instruction
············· nop·· ' this makes a world of difference!?· Could there be pre fetching?
· Writer··· wrlong 10, DiagHubAddress ' note that·10 is a dummy field value here, it is overwritten every loop
············· ...
············· jmp #looptop

Without the NOP instruction, the affect of changing the desitnation field only works the next time around in the loop.· With the NOP instruction, the Writer WRLONG instruction works as I planned.

Can anybody confirm this prefetch?

Eric R

Comments

  • JT CookJT Cook Posts: 487
    edited 2008-03-31 15:41
    I cannot remember where I read it, but I do know that you need an instruction between modifying code (MOVS, MOVD) and the code that is being modified. So you would need a NOP or another instruction inbetween, most like due to the fact that the Propeller is fecting the next instruction.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 16:42
    Yes, the next instruction is fetched late in the execution of an instruction, so you have to have some other instruction (doesn't have to be a NOP) between one instruction and the instruction modified by it.
  • EricREricR Posts: 35
    edited 2008-03-31 19:34
    Thanks Mike and TJ.· I think I may submit a suggestion about this being added to the Propeller documentation.
  • TreeLabTreeLab Posts: 138
    edited 2008-03-31 20:19
    This is discussed in DeSilva's tutorial on Propeller asm coding, along with the timing diagrams for the prefetch etc. By coincidence, I found this out last night!
  • EricREricR Posts: 35
    edited 2008-04-01 12:11
    TreeLab,
    I found (or rather Google found) the deSilva Assembly Tutorial at http://www.vaguelogic.com/propeller/Programming/DeSilvaAssemblyTutorial.pdf . I am enjoying reading this, thanks for the reference.
    Eric
Sign In or Register to comment.