This seems a little odd but for some reason I can only do binary operations in inline assembly blocks.
In the following example the function takes a lowercase character and XORs it with 00100000 to convert it to an uppercase character.
Code:
char charupper( char c )
{
if ( c & ( 1 << 5 ) ) // Is bit 5 set?
{
__asm // Start inline assembly
{
mov al, c // Move the character into the al register
xor al, 00100000b; // XOR the al register with 00100000 which will invert bit 5
} // End inline assembly
}
else
return c; // If the character was already uppercase, return the same character
}
That function works as expected but is limited to x86 based machines.
Is there a way to do the same thing with C?
Thanks in advance for any advice you can give.