Assuming I have a negative 8-bit number represented in 2 complement code, let's say -12, what number can I add to it to set all flags mentioned in the title (Zero, Negative, Overflow and Carry), or at least 3 of them?

My understanding now is that 8 bit 2 complement code can only represent numbers from -128 to 127, so when I have -12 I can add +12 and I will set the carry and zero flag. The other way would be to add a negative number to -12 that will be equal to a positive 8 bit number(e.g. -12-120), which means I will set my overflow and carry flags.

So is there a way to set all of the flags or at least three of them ?

  • $\begingroup$ Can 0 be a negative number? The flags are based upon the result of caculation. So no! $\endgroup$ – StainlessSteelRat Nov 6 '20 at 1:19
  • $\begingroup$ It seems obvious that the answer can't be zero and negative at the same time. $\endgroup$ – user253751 Nov 11 '20 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.