Fast method for Reverse Sign Extend?
T Chap
Posts: 4,223
I want to send out a signed long as a signed word, but don't see an operator that is the reverse of the signed extend from 15 to 31. I was wondering if there was a fast method in SPIN as single operator to move bit 31 to 15. Does anyone have a trick for a the fastest method in SPIN to move bit 31? All I can think of is:
Or
If SignedLongVariable < 0 WordVariable := %1000_0000_0000_0000 |= SignedLongVariable ' value does not exceed +/- 2000 ' compute checksum ser.tx(PacketHeader) ser.tx(PacketLength) ser.tx(Opcode) ser.tx(WordVariable) ser.tx(WordVariable>>8) ser.tx(checksum)
Or
WordVariable := SignedLongVariable + SignedLongVariable >> 16
Comments
-Phil