I have a variable:
ushort statusRegister;
This variable tracks the result of various computations by way of the setting or clearing of its individuals bits. The bits are defined as:
- Bit0 = carry
- Bit1 = overflow
- Bit2 = Zero
- Bit3 = Sign
- Bit4 = IRQ
- Bit5 = Aux Carry
- Bit6 = 1 Not used
- Bit7= 1 not used
Given the following:
Ushort varA = 0x8B;
Ushort varb = 0x24;
Ushort result = varA + varB;
How do I set or clear these individual bits given the result of the computation? I can't figure out how to determine if the computation caused a bit carry or half carry or if an overflow occurred.
Thanks for any advice