Shop OBEX P1 Docs P2 Docs Learn Events
Optimal SPIN Sign-Extend Bit-7 (~X) Port to PASM? — Parallax Forums

Optimal SPIN Sign-Extend Bit-7 (~X) Port to PASM?

DroneDrone Posts: 433
edited 2009-08-30 10:15 in Propeller 1
Still cutting my teeth on PASM. Given that (go easy on me):

There seems to be no equivalent PASM unary operator to the SPIN ~ sign-extend from bit-7 (~X) operator (correct me if I'm wrong please).

So, what is the most efficient way to port the very useful SPIN unary pre-clear (my words vs. post-clear) operator ~X to PASM?

Reference:

~ Sign-extend from bit 7 (~X) - Propeller Manual V1.1 Pgs, 42 $ 156.

I'm interested in the ~X usage, not post-clear, X~

I'm working with a Long in PASM where only the least significant byte will be the source ('signed' 8-bit where bit 7 is the sign +/-), all higher source bytes are zero at outset.

There seems to be many ways to do this in PASM (hence my question). But I'm guessing someone has already optimized this for minimum PASM clock cycles.

All I want to do is optimally port the SPIN ~X unary operator to PASM for long sources of the form $0000_00XX.

Thanks for any replies, and apologies if I haven't formulated my question properly (part of learning process IMHO)

Rgds, David

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-29 16:30
    shl  x, #24  'shift bit 7 (sign bit ) to bit 31
    sar x, #24  ' shift back with sign extension
    
    
  • DroneDrone Posts: 433
    edited 2009-08-30 10:15
    Perfect, Thanks Timmore - Daivd
Sign In or Register to comment.