PDA

View Full Version : assembly cmp help



mctrivia
01-19-2009, 03:52 PM
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?

Coley
01-19-2009, 04:06 PM
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 (http://www.propgfx.co.uk) - The home of the Hybrid Development System and PropGFX Lite

mctrivia
01-19-2009, 04:21 PM
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

Coley
01-19-2009, 04:24 PM
It would be easier to help you if you showed the whole of this asm routine you are trying to debug... http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PropGFX (http://www.propgfx.co.uk) - The home of the Hybrid Development System and PropGFX Lite

mctrivia
01-19-2009, 04:27 PM
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

Cluso99
01-19-2009, 04:31 PM
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

mctrivia
01-19-2009, 04:48 PM
that was it thanks

Ale
01-19-2009, 04:50 PM
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.