src/common/xed-util.c
/* arbitrary sign extension from a qty of "bits" length to 64b */
arbitrary sign extension from a qty of "bits" length to 64b
arbitrary sign extension from a qty of " bits " length to 64b
xed_int64_t xed_sign_extend_arbitrary_to_64(xed_uint64_t x, unsigned int bits) {
    xed_uint64_t one = 1;
    xed_int64_t mask = one<<(bits-1);
    xed_int64_t vmask, o=0;
    if (bits < 64) {
        vmask = (one<<bits)-1;
        o = ((x&vmask) ^ mask)- mask;
    }
    else if (bits == 64) 
        o=x;
    else 
        xed_assert(0);
    return o;
}
xed_int64_t xed_sign_extend_arbitrary_to_64 ( xed_uint64_t x , unsigned int bits ) { xed_uint64_t one = 1 ; xed_int64_t mask = one << ( bits - 1 ) ; xed_int64_t vmask , o = 0 ; if ( bits < 64 ) { vmask = ( one << bits ) - 1 ; o = ( ( x & vmask ) ^ mask ) - mask ; } else if ( bits == 64 ) o = x ; else xed_assert ( 0 ) ; return o ; }
arbitrary sign extension from a qty of "bits" length to 64b
arbitrary sign extension from a qty of " bits " length to 64b