Shop OBEX P1 Docs P2 Docs Learn Events
Assembler question — Parallax Forums

Assembler question

micman2micman2 Posts: 18
edited 2009-05-08 18:52 in Propeller 1
Hi all,

I've a question about the load variable:
I use viewport for read into the variable

When I'd write in temp1 with 100 , work! (screen "a" and "a1" file in a1 see variable "v2")

              mov temp1,#100




but when I load temp1 with variable "Delay" not work!!!(screen "b" and "b1" file see variable "v2")


              mov temp1,Delay

              Delay         long    100





Send screen
890 x 464 - 12K
276 x 126 - 3K
288 x 144 - 4K
812 x 381 - 8K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-08 16:11
    The problem is your Delay declaration. You can't have a LONG declaration in the middle of a series of RES declarations. The RES declarations must always come last in the cog program.
  • micman2micman2 Posts: 18
    edited 2009-05-08 16:29
    How I do ?

    and another question , If I would load variabile with 1000 I have a error! but the register is 32bit?!
    572 x 279 - 14K
  • AleAle Posts: 2,363
    edited 2009-05-08 16:36
    The literal immediate (using #) is limited to values between 0 and 511. Use a variable to load bigger constants (like you do in your second example above). (Read the multiple assembler tutorials that the first sticky in the forum has [noparse]:D[/noparse], it will dissipate loads of doubts.
  • micman2micman2 Posts: 18
    edited 2009-05-08 16:44
    Ok tanks!!! wink.gif

    Another question redface.gif

    I would developement delay but without use waitcnt

    My simple code:

    
    '---------delay
                      mov temp,cnt
                      add temp,Delay
    mylop         cmp temp,cnt
    IF_B           jmp mylop                    ' if temp is below cnt counter
              
    '........... 
    
    
    Delay         long    4_000_000
    
    temp res 1
                                               
    
    




    Is it correct?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-08 17:05
    This will work better:
                      mov  startTime,cnt             ' Save starting time
    delayLoop   mov  temp,cnt
                      sub   temp,startTime          ' Compute difference between now and starting time
                      cmp  temp,Delay        wc    ' Is difference less than desired delay
            if_b     jmp  #delayLoop               ' If so, continue to wait
    


    The reason for comparing to the time difference is that it avoids problems when the time wraps around (in the 32 bit register).
  • micman2micman2 Posts: 18
    edited 2009-05-08 17:11
    Thank thank!! smile.gifsmile.gif
  • AleAle Posts: 2,363
    edited 2009-05-08 18:52
    In your example, you are jumping _after_ the addition, so you are always comparing and jumping but never adding
Sign In or Register to comment.