Shop OBEX P1 Docs P2 Docs Learn Events
assembly cmp help — Parallax Forums

assembly cmp help

mctriviamctrivia Posts: 3,772
edited 2009-01-19 08:50 in Propeller 1
  cmp       ulMSec,ulDayLength              'See if day done
  if_b  jmp       :updateTime                     'If day is done jump to end of routine




The manual says if ulMSec is less then ulDayLength then c=1
if c=1 then if_b should be true and execute command.

ulDayLength=86_400_000
ulMSec will almost always be less the that. why does the line after this execute every time?

Comments

  • ColeyColey Posts: 1,110
    edited 2009-01-19 08:06
    Hi mctrivia

    It's because you haven't indicated which flag to set.

    try

    cmp       ulMSec,ulDayLength  wc            'See if day done
    




    Here the C flag will be set if ulMSec is less than ulDayLength

    regards,

    Coley

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX - The home of the Hybrid Development System and PropGFX Lite
  • mctriviamctrivia Posts: 3,772
    edited 2009-01-19 08:21
    ok that works but for some reason it resets to a value other then 0?

                  cmp       ulMSec,ulDayLength      wc              'See if day done
            if_b  jmp       :updateTime                     'If day is done jump to end of routine
    
                  'run every day
                  mov       ulMSec,#0  
    
    
  • ColeyColey Posts: 1,110
    edited 2009-01-19 08:24
    It would be easier to help you if you showed the whole of this asm routine you are trying to debug... smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX - The home of the Hybrid Development System and PropGFX Lite
  • mctriviamctrivia Posts: 3,772
    edited 2009-01-19 08:27
    here it is

    DAT
                  org       0
                  
                  
    TimeKeeper    mov       cnt_value,cnt                   'prepare for initial waitcnt
                  add       cnt_value,cnt_ticks
                  
                  'run every ms
    :loop         waitcnt   cnt_value,cnt_ticks
                  rdlong    ulMSec,ptrToUlTime              'Copy sec over
                  add       ulMSec,#1                       'Add 1 to MSec
                  cmp       ulMSec,ulDayLength      wc              'See if day done
            if_b  jmp       :updateTime                     'If day is done jump to end of routine
    
                  'run every day
                  mov       ulMSec,#0                       'Set Time to midnight
    {              rdlong    ulDat,ulDate                   'Copy days over
                  add       ubDay,#1                        'Add 1 day
                  mov       ulTemp,#months+ubMonth
                  'have not figured out how to do calendar yet
    }              
    
                  'finish up                                          
    :updateDate   wrlong    ulDat,ulDate                    'Update the date
    :updateTime   wrlong    ulMSec,ptrToUlTime                   'Update the time
                  jmp       #:loop
    
    
    'Locale Time Value
    ulMSec        long      0
    ptrToUlTime   long      0      
                               
    'Locale Date Values
    ulDat
    uwYear        word      0
    ubMonth       byte      0
    ubDay         byte      0
    
    'Lenght of Month Table
    months
    january       byte      31
    february      byte      28
    march         byte      31
    april         byte      30
    may           byte      31
    june          byte      30
    july          byte      31
    august        byte      31
    september     byte      30
    october       byte      31                       
    november      byte      30
    december      byte      31
    
    'constants
    zero          long      0           
    ulDayLength   long      86_400_000 
    cnt_ticks     long      80_000
    cnt_value     long      0
                  fit       496  
    
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-01-19 08:31
    Probably your jump should be
    jmp #:updateTime

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Prop Tools under Development or Completed (Index)
    http://forums.parallax.com/showthread.php?p=753439

    My cruising website http://www.bluemagic.biz
  • mctriviamctrivia Posts: 3,772
    edited 2009-01-19 08:48
    that was it thanks
  • AleAle Posts: 2,363
    edited 2009-01-19 08:50
    There is no access to bytes or words in COG assembly. You can only access longs and they will be long aligned because all addresses are long aligned with long granularity:

    Address 0 is the first long
    Address 1 is the second long.

    There is no byte granularity or word.

    To access ubDay I'll do this:

       mov  temp, ulDat
       shr  temp, #24   ' temp has now ubDay
    ...
       mov temp, ulDat
       shr  temp, #16
       and temp, #255    ' temp has now ubMonth
    ...
    
    



    I'd recommend you download pPropellerSim (from sourceforge.org/projects/ppropellersim) and test them through.
Sign In or Register to comment.