Shop OBEX P1 Docs P2 Docs Learn Events
? MOVS instruction — Parallax Forums

? MOVS instruction

Marc GebauerMarc Gebauer Posts: 60
edited 2007-01-29 21:50 in Propeller 1
Can anyone clarify for me what the·MOVS instruction does? What does it mean that·the 9-bit·value of VALUE·is·copied into·bits 0..8 of the·destinations source? What is the destinations source? How is·MOVS used? Thanks...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • CJCJ Posts: 470
    edited 2007-01-22 01:13
    it sets bits 8...0 of the destination register to either the literal contained in the source field of the MOVS instruction or bits 8...0 of the register pointed to by the source of the MOVS instruction

    can be used to change the address used in a JMP instruction at runtime, for a state machine perhaps

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-01-22 01:26
    The most common use of MOVS is to work with arrays of data. By taking the base address of an array and adding the index into the array then writing this value·using MOVS on the instruction that is accessing the array, the entire task can be accomplished without the need for special index registers as required on other microcontrollers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • peterzpeterz Posts: 59
    edited 2007-01-29 19:11
    Paul, may you post an example of how to use MOVS to access arrays ?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-01-29 21:50
    Rather than MOVS, I'll show MOVD, its used in the same way.
    zeromem    movd :zloop, :cptr        'init destination pointer
               nop                       '1 instruction must be between movd and execution of instruction movd modified
    :zloop     mov 0_0, :zero            'zero out a memory location
               add :cptr, #1             'increment pointer
               movd :zloop, :cptr        'update pointer in the instruction using it
               djnz :i, :zloop
     
    ;zero      LONG 0
    :cptr      res 1
    :i         res 1     
     
            
    

    This function zero's out a portion of the cog memory between cptr and cptr+i, where cptr and i are initialized before this function is executed. In this example it would be faster to increment :zloop's instruction directly by $0000_0200, but you asked for an example using the MOVx·instruction.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.