Shop OBEX P1 Docs P2 Docs Learn Events
SHL instruction, strange results ? — Parallax Forums

SHL instruction, strange results ?

scottascotta Posts: 168
edited 2009-04-13 21:51 in Propeller 1
Can someone confirm this (or explain it): I am using the SHL instruction
on a negative number. The documentation states bits are simply shifted
to the left, the sign is not supposed to be maintained. It looks like SHL
is acting more like the SAR instruction.

mov t1,#50
neg t1,t1
shl t1,#2
wrlong t1,debug

debug shows -200

Comments

  • KyeKye Posts: 2,200
    edited 2009-04-13 21:49
    Um, yeah, look at what your doing...

    50 = 0000 0000 0000 0000 0000 0000 0011 0010

    -50 = 1111 1111 1111 1111 1111 1111 1100 1110

    shl #2 = 1111 1111 1111 1111 1111 1111 0011 1000

    Which is some negative number...

    Windows calculator messes up the sign extension so I don't know what that number is,

    Mostlikely -200 however...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • scottascotta Posts: 168
    edited 2009-04-13 21:51
    [noparse]:)[/noparse]

    50 != 1000 0000 0000 0000 0000 0000 0011 0010

    Sometimes you can stare at it all day.....

    Thanks Kye !
Sign In or Register to comment.