Shop OBEX P1 Docs P2 Docs Learn Events
PASM MOV to Array Question — Parallax Forums

PASM MOV to Array Question

Pascal22Pascal22 Posts: 2
edited 2010-08-28 15:00 in Propeller 1
hi,

how to make something like this in PASM : (write a value in an array)

MOV TmpVal, Adr_2_Array
ADD TmpVal, Offset
MOV TmpVal, Value

Adr_2_Array contain the base adresse of an array localised in the cog memory
Offset contain a position in the array

the last line do not work : the value is moved in the TmpVal register and not in the (adresse_of_array+offset) register


sorry for my poor english...:shakehead:

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-28 11:57
    You actually have to modify the instruction itself like this:
    movd  copyInst, #addressOfArray ' initialize to address of array
               shl   offset, #9 ' position offset to destination field bits
               add   copyInst, offset ' add modified offset to instruction
               shr   offset, #9 ' delay required here, might as well correct offset
    copyInst   mov   0-0, valueToCopy ' copy value, "0-0" is just a placeholder
    
    Note that you need a one instruction delay between the last change to the
    instruction and when it's executed. The 2nd SHR serves as the delay and it
    repositions the offset back to where it was originally. You could use any other
    single instruction (like a NOP) for the same purpose.

    The "0-0" is just a placeholder to show you which fields of which instructions are
    calculated at run time. You could use just "0" if you want, but "0-0" can be more
    meaningful.
  • Pascal22Pascal22 Posts: 2
    edited 2010-08-28 13:38
    thank's for the response.

    I unterstand that must have 4 instructions between the movd and the modified instustion (4 cycles of decoding by instruction)... that's right ?

    Another question :

    the cog's memory is long aligned, so the offset's step is 1 vs hub's memory who the offset's step is 4 (for a long value) ?
  • jazzedjazzed Posts: 11,803
    edited 2010-08-28 14:54
    Pascal22 wrote: »
    I unterstand that must have 4 instructions between the movd and the modified instustion (4 cycles of decoding by instruction)... that's right ?
    Only one instruction is necessary between movd,movs,movi and the modified instruction.
    Pascal22 wrote: »
    the cog's memory is long aligned, so the offset's step is 1 vs hub's memory who the offset's step is 4 (for a long value) ?
    Yep you got it.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-28 15:00
    Remember that the ADD instruction also changes the MOV instruction and the one instruction delay is from the ADD to the MOV.
Sign In or Register to comment.