Shop OBEX P1 Docs P2 Docs Learn Events
transfer from spin to assembly problem solved — Parallax Forums

transfer from spin to assembly problem solved

Julian800Julian800 Posts: 31
edited 2010-06-09 11:38 in Propeller 1
Hi All,
I am tring to transfer some Spin into assembly. I stuck with some·error code(Just can't find where is the problem ). the code is Ramp up frequency of counter.

if NextFreqRegA <> frqa
············ repeat·· until NextFreqRegA == frqa
··············· Delay :=clkfreq/1_000 + cnt
·············· if NextFreqRegA > frqa
··················· frqa :=· frqa + RampSpeed <# NextFreqRegA
·············· elseif· NextFreqRegA < frqa················
··················· frqa := frqa· - RampSpeed #> NextFreqRegA
············· waitcnt(Delay)
·········
········
Ramp······
·········· Cmp··· frqa,· Retun WZ , WC···················· '·Return is·NextFreqRegA in Spin
·········· IF_E· Jmp· #CalcFrqReg··
················ Mov·· Temp, frqa
·········· if_c· Add·· Temp , PerStep
·········· if_c· Max·· Temp , Retun
·········· if_nc· Sub·· Temp , PerStep
·········· if_nc· Min·· Temp , Retun
·········· Cmp· frqa, Zero··· WZ
··········· IF_NE· WAITPEQ···port , #%0010
··········· IF_NE· WAITPNE·· port, #%0010
·········· Mov·· frqa, Temp
·········· wrlong· Temp, ReturnAddr
·········· Mov··· Time , cnt
·········· Add··· Time ,Delay
·········· waitcnt Time ,Delay
·········· JMP· #Ramp
········

Post Edited (pussycat) : 6/9/2010 11:56:56 AM GMT

Comments

  • pullmollpullmoll Posts: 817
    edited 2010-06-09 10:40
    Julian800 said...
    Hi All,
    I am tring to transfer some Spin into assembly. I stuck with some error code(Just can't find where is the problem ). the code is Ramp up frequency of counter.



    if NextFreqRegA <> frqa 
                 repeat   until NextFreqRegA == frqa    
    
                    Delay :=clkfreq/1_000 + cnt 
                   if NextFreqRegA > frqa 
                        frqa :=  frqa + RampSpeed <# NextFreqRegA    
                   elseif  NextFreqRegA < frqa                 
                        frqa := frqa  - RampSpeed #> NextFreqRegA
                  waitcnt(Delay)
              
    
             
    Ramp       
               Cmp    frqa,  Retun WZ , WC                     ' Return is NextFreqRegA in Spin
               IF_E  Jmp  #CalcFrqReg   
                     Mov   Temp, frqa 
               if_c_and_nz  Add   Temp , PerStep
               if_c_and_nz  Max   Temp , Retun
               if_nc_and_nz  Sub   Temp , PerStep
               if_nc_and_nz  Min   Temp , Retun
               Cmp  frqa, Zero    WZ
                IF_NE  WAITPEQ   %0000 , %0010
                IF_NE  WAITPNE   %0000 , %0010
    
               Mov   frqa, Temp
               wrlong  Temp, ReturnAddr
               Mov    Time , cnt
               Add    Time ,Delay
               waitcnt Time ,Delay 
               JMP  Ramp 
    
             
    Zero                    long    0
    Retun                   long    0
    Temp                    long    0
    PerStep                 long    53687 
    Time                    res     1
    


    Looks better with (code)(/code) tags.
    The JMP Ramp should be JMP #Ramp. There are very few occasions where a jmp does not need a # in front of the address (register jumps).
    Not sure what your WAITPEQ/WAITPNE are supposed to do, as there are no equivalent lines in the Spin source. You usually specify a destination register (label) and it looks like the source fields (%0010) are both supposed to be immediate values, so it needs a # before them. I guess you want to write waitpeq portval, #%0010 with portval long %0010 in the variables section.
    In the lines with conditions if_c_and_nz and if_nc_and_nz you can strip the _and_nz, because before them you already jumped on the if_e (= if_z) condition.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pullmoll's Propeller Projects

    Post Edited (pullmoll) : 6/9/2010 10:50:28 AM GMT
  • Julian800Julian800 Posts: 31
    edited 2010-06-09 11:38
    thanks pullmoll for your help. that is realy sily mistake.

    WAITPEQ waite· pin tranafer state, so I can keep wave in highspeed updeate

    Post Edited (pussycat) : 6/9/2010 11:53:45 AM GMT
Sign In or Register to comment.