SHL instruction, strange results ?
scotta
Posts: 168
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
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
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,
50 != 1000 0000 0000 0000 0000 0000 0011 0010
Sometimes you can stare at it all day.....
Thanks Kye !