0

Datasheet for the Intel 8008 CPU mentions that the Carry (C) flag is affected with the logic operations (AND, OR, XOR), but it does not make any sense. I believe Carry will be zeroed, but I have no proof of this conclusion.

What is the exact behaviour of the Carry flag?

3

Datasheet for the Intel 8008 CPU mentions that the Carry (C) flag is affected with the logic operations (AND, OR, XOR), but it does not make any sense. I believe Carry will be zeroed, but I have no proof of this conclusion.

First, the manual does not say anything special about logic operations but states:

The result of the ALU instructions affect all of the flag flip-flops.
The rotate instructions affect only the carry flip-flop.

(From the 1973 User Manual section IV.B p.8)

Second, yes and no. Carry will not explicite forced to clear, but reflects, like the other flags, whatever the ALU output was (after any ALU operation). In case of logic operation this means

  • Zero set if the result is all zero
  • Sign set to the top bit
  • Parity set according to the 1 bit sum of all bits
  • Carry cleared, als logic never generates carry
| improve this answer | |
  • 2
    I understand the point. My expression was a shortened version for the final effect: logic never generates carry => C flag is taken from the ALU => logic instructions do clear the carry (because it never generates carry). – Martin Maly Aug 1 at 17:06
  • @MartinMaly so it is. – Raffzahn Aug 1 at 17:07
  • @MartinMaly Just as a remark. When dissecting the workings of a CPU, shortcuts aren't always a good idea - at least not if you want to do an exact emulation. – Raffzahn Aug 1 at 18:14
  • I agree. It is good to know the principle and essence. But sometimes you have to prefer "effect" over "essence" - i.e. when you want to emulate only on the top level, not the cycle-perfect machine. In such a case you can emulate only the result, like "C is always 0 after the logical instructions". :) – Martin Maly Aug 1 at 19:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.