RE: Bit masking and shifts 08-31-2015, 02:05 AM
#11
(08-31-2015, 01:51 AM)eclipse Wrote: What's the point of having a carry? Surely 11000000 -> 10000001 --> 00000011 is more useful than 11000000 --> 10000000 --> 00000001 --> 00000011
its useful for data conversion. Take for example the operation 0xff+0x1. We know that the maximum value a byte can hold is 0xff, but yet somehow it knows that 0xff+0x1=0x100. This is done with the carry. Rotating through carry, not always useful, but shifting through it is. 0x8f * 0x2. We do that by shifting it left once through the carry. Then we know that there was an overflow (or can handle multibyte oprations) since most CPU's do not set the V flag on unsigned operations.

























![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)
