Assembly Question - Time Difference
mynet43
Posts: 644
Can someone tell me the proper way to subtract two numbers in assembly to get a time difference?
I'm trying to get a time difference using cnt.
If I use:
mov dt,cnt
sub dt,old_t
Then I may get a negative number, if cnt has wrapped around it's 32 bits.
I know I can set the carry to tell if dt is less than old_t, but I'm not sure what to do if it is.
My time differences will always be less than 1 second.
So what is the correct way to always get a positive time difference.
Thank you for your help.
Jim
I'm trying to get a time difference using cnt.
If I use:
mov dt,cnt
sub dt,old_t
Then I may get a negative number, if cnt has wrapped around it's 32 bits.
I know I can set the carry to tell if dt is less than old_t, but I'm not sure what to do if it is.
My time differences will always be less than 1 second.
So what is the correct way to always get a positive time difference.
Thank you for your help.
Jim
Comments
http://www.parallax.com/portals/0/propellerqna/
your answer is pretty much down in the middle.
Consider this:
Old time is some very big unsigned number, for example in Hex:
$FFFFFFF0
And your new time is some small unsigned number, after CNT has rolled over:
$00000005
What is the elapsed time?
new - old = $00000005 - $FFFFFFF0 = $00000015
If you don't believe it try it on your calculator in hex mode and keeping only the lower 8 hex digits.
Magically, despite the wrap around of CNT, that is the correct answer.
As SUB in PASM is unsigned it to will give the correct result.
Up until the time difference is greater than $FFFFFFFF. About 40 seconds for an 80MHz Prop.
Thanks so much for all the great feedback!
It all makes sense now.
I think I've got it!
Jim
All the characters are displaying wrongly. Looking around I find a lot of the text is gibberish too.
Is this just me and my IceWeasle browser on Debian or what?
I not have any problems.
On Win XP with Firefox
I think it's your browser or possibly not having the font installed.
I have no problem reading it with XP/Firefox.
-Phil
Surely a web page should not depend on having the Parallax font installed.
It's not your browser. I looked at the site with Opera under Ubuntu and got the same gibberish you did. With Opera under OS/X, the site hangs completely until I hit stop (X). Then the left menu is mostly absent. This did not happen on Ubuntu, though. There's definitely something wacky about that site.
-Phil
I have no problem running iep8 on xp.
train nut