The codes in C++ but its an assembly question... I got lots of views in that forum but no answers, so here it goes lol:
unsigned SetBit(unsigned BitMap, unsigned position)
{
return BitMap | (1 << position);
}
unsigned ClrBit(unsigned BitMap, unsigned position)
{
return BitMap & ~(1 << position);
}
54)In code appearing in the questions above, explain what happens if the position parameter contains a value greater than or equal to the number of bits in an unsigned integer.
Unless I'm confused... in assembly you would need to put the one in a register, then shift it to the left n times, where n is the number of bits in the unsigned variable, then take the smallest register containing the set bit that you shifted, and OR it with the unsigned variable. But this would return a compile error because the operands must be the same size.
Would the compiler just extend the memory location? Or would it return a value out of range exception or a conversion error exception? Thanks for your help.


Sign In
Create Account


Back to top









