I want to implement the sign and zero flag setting in microprocessor. So I need to write a function to find whether the number is positive, negative or zero without using if
or for
loops and also only Boolean and bitwise operators are allowed. I did the following. But how to I implement it for zero
condition ?
int status (int x) {
int sign = (x >> 31);
return sign;
}
Any suggestions ?