#40 ((x>>4)|(x<<4))

closed
Erik Petrich
None
1
2003-11-06
2003-11-01
No

Almost all 8 bit architectures know a
command to swap nibbles within a byte.
Still very few compilers will recognize
this term - it would be nice if SDCC would
treat this like the "highest order bit"
and generate a "swap a".

Frieder

Discussion

  • Erik Petrich
    Erik Petrich
    2003-11-06

    Logged In: YES
    user_id=635249

    As of ChangeLog 1.492, this is now supported on the hc08,
    mcs51, and ds390 ports. The C front end is actually looking
    for something in the form

    ((x>>b)|(x<<b)) or (x<<b)|(x>>b))

    where b=(sizeof(x)*4) and x is unsigned. I implemented the
    cases of b==4 and b==8 (swap nibbles or swap bytes); the
    unimplemented cases will fall back to the original
    unoptimized shift/shift/or code generation.

     
  • Erik Petrich
    Erik Petrich
    2003-11-06

    • assigned_to: nobody --> epetrich
    • status: open --> closed