Shop OBEX P1 Docs P2 Docs Learn Events
MOVS and MOVD — Parallax Forums

MOVS and MOVD

Bobb FwedBobb Fwed Posts: 1,119
edited 2009-09-11 23:03 in Propeller 1
I am trying to reset an instruction's destination and source. I am hoping there is a way to set both at the same time.
To progress it, I am adding 1 << 9 + 1 to the value, but to set it back to the original location what's the fastest way?

Here is clips of what I am doing:
timeh         IF_Z      ADD     time, pinhighs
                        ADD     timeh, dsplus1

                              [i]_with_[/i]

reset                   MOVD    timeh, #time
                        MOVS    timeh, #pinhighs

dsplus1                 LONG    1 << 9 + 1                                      ' destination and source plus one value
pinhighs                LONG    0 [noparse][[/noparse]31]

time                    RES     31



Can I do that reset section in one instruction? It is is a known number of additions. So I guess I could SUB it...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2009-09-11 15:54
    Can't you just store the original instruction, then move it, when it's time for a reset?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
    Safety Tip: Life is as good as YOU think it is!
  • Agent420Agent420 Posts: 439
    edited 2009-09-11 16:04
    > So I guess I could SUB it...


    I'm still a bit young in pasm, but that would be my guess.· In fact, that's one of the tricks I picked up studying Chip's vga driver code...

    sub timeh, reset_addr  
     
    reset_addr     long   (1 << 9 + 1) * < # of iterations >
    

    edit - oops, had reser as immediate

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


    Post Edited (Agent420) : 9/11/2009 4:09:18 PM GMT
  • JavalinJavalin Posts: 892
    edited 2009-09-11 19:12
    this might help - not sure.

    http://obex.parallax.com/objects/268/

    Example of using movd / movs for self modifying code

    J
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-09-11 19:18
    potatohead has the right idea on this one.

    -Phil
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-09-11 23:03
    So something along these lines:
                            MOV     timehbak, timeh
    loop
    timeh                   ADD     time, pinhighs
                            ADD     timeh, dsplus1
    
                                  [i]_with_[/i]
    
    reset                   MOV     timeh, timehbak
    
    dsplus1                 LONG    1 << 9 + 1                                      ' destination and source plus one value
    pinhighs                LONG    0 [noparse][[/noparse]31]
    
    time                    RES     31
    timehbak                RES
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
Sign In or Register to comment.