cpu/cpu.c
// sign extension:
// extend the number x stored in
// b bits to a 16 bit int
sign extension:
extend the number x stored in
b bits to a 16 bit int
sign extension : extend the number x stored in b bits to a 16 bit int
int16_t SEXT(x,b){
    int m = 1U << (b - 1);
    x = x & ((1U << b) - 1);
    return (x^m)-m;
}
int16_t SEXT ( x , b ) { int m = 1U << ( b - 1 ) ; x = x & ( ( 1U << b ) - 1 ) ; return ( x ^ m ) - m ; }
sign extension:
extend the number x stored in
b bits to a 16 bit int
sign extension : extend the number x stored in b bits to a 16 bit int