Shop OBEX P1 Docs P2 Docs Learn Events
two-instruction method to rotate carry-Not into register? — Parallax Forums

two-instruction method to rotate carry-Not into register?

agsags Posts: 386
edited 2013-08-27 10:04 in Propeller 1
Is there any way to rotate the negated value of the carry flag into a register? I see such an instruction doesn't exist, but is there an ingenious way to do this in two instructions? There's a muxnc for muxc, a negnc for negc, but no rcnr for rcr. The application is difficult to explain, and I can simply xor the final result with -1. That causes some other problems. The typical code is:
        shr  reg1, #1  wc
        rcr  reg2, #1

I'm looking to get the inverse of the LSB of reg1 shifted (rotated) into the MSB of reg2, in two instructions. Is that possible?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-08-26 10:40
    If you use the same register for the input and the output, you can do:
                    shr   reg, #1   wc
                    muxnc reg,bit31
    
    bit31 is a long containing |<31. Depending on what you want to do with the result, you may need some cleanup afterwards. If reg just contains an 8-bit value, you're done after 8 of these.
  • lonesocklonesock Posts: 917
    edited 2013-08-26 11:53
    I'm guessing pre-XORing reg1 with -1 is not an option either?

    Jonathan

    P.S. I was wishing for a ADDNX command, but alas, it is not available.
  • agsags Posts: 386
    edited 2013-08-26 12:04
    @Mike Green: I need to strip one bit at a time, invert it, and then distribute to one of 32 target registers - so that won't help for my situation.
    @lonesock: I am using an xor now, but it's messy and I was hoping for an alternative.

    Thanks.
  • lonesocklonesock Posts: 917
    edited 2013-08-27 10:04
    Any chance you could post a working segment of code so I can play with it? This sounds like a fun challenge.

    Jonathan
Sign In or Register to comment.