Shop OBEX P1 Docs P2 Docs Learn Events
Shift Arithmetic Right in Assembly — Parallax Forums

Shift Arithmetic Right in Assembly

velocityxlrgvelocityxlrg Posts: 18
edited 2006-12-24 17:49 in Propeller 1
I've been using the following in spin:

x:=100000
temp:=x + cnt
repeat
if (temp-cnt) ~> 31 'shift arithmetic right
do stuff, time's up...
else
do something else, keep waiting...


I got this from a post from Mike Green and it works, but try as I might I don't understand how.
The problem is now I would like to translate it into assembly, but my lack of understanding is
preventing me from making any progress.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-24 07:30
    All the shift right does is to change a negative number into a -1 which is TRUE and a positive number (including zero) into a 0 which is FALSE.
    You could do the same thing with "temp - cnt < 0" instead of "(temp-cnt) ~> 31".

    It shifts the sign bit all the way to the right replacing all the bits of the number.
  • velocityxlrgvelocityxlrg Posts: 18
    edited 2006-12-24 17:49
    Thanks Mike, I ran a few simulations and it makes more sense now.
Sign In or Register to comment.