0
10011100   +
01010000
---------

For this expression, how can I know what will be the CF and the OF after calculating the expression?

Lior
  • 5,841
  • 9
  • 32
  • 46
  • x86, I presume? And an 8-bit addition? – harold Oct 20 '12 at 16:03
  • It'd be helpful to mention that (most likely) this is for x86. There's more to the CPU universe than just Intel, you know... – Marc B Oct 20 '12 at 16:03
  • If you're trying to emulate the addition instruction (or subtraction or comparison), [this answer](http://stackoverflow.com/a/8037485/968261) should help. – Alexey Frunze Oct 21 '12 at 05:17

1 Answers1

2

First, you add them.

10011100   +
01010000
---------
11101100

For CF: was there a carry-out? Not in this case, so CF is zero.

For OF: is the carry into the signbit different from the carry-out? Not in this case, so OF is zero.

harold
  • 61,398
  • 6
  • 86
  • 164
  • Can you explain what is a carry-out? – Lior Oct 20 '12 at 16:12
  • @user1718294 when you add numbers you get carries sometimes, the carry-out is the carry that "falls off the edge" (because the number has a fixed length). – harold Oct 20 '12 at 16:13