assemblyintel-8080

INTEL 8008/8080/8085 subtraction


I cannot find any reference to such a specific situation related to the subtraction operation done by INTEL 8008, 8080 and 8085. The topic, here, is the inverted carry (i.e. a borrow), that subtraction performs at the end

Now how does the processor deal with subtracting by 0? Because the two's complement of 0 is 0, there will be no carry-out, so following the subtraction logic, the carry will be always set (i.e. meaning a borrow happened), but in this case, it is wrong.

Is the processor applying in this case the logic of the addition operation, where the carry is not inverted?

thanks a lot,

Fausto


Solution

  • Now how does the processor deal with subtracting by 0? Because the two's complement of 0 is 0, there will be no carry-out, so following the subtraction logic, the carry will be always set (i.e. meaning a borrow happened), but in this case, it is wrong.

    No. The logic used for subtraction is to complement the second operand, then add together the first operand, the complemented second operand, and the carry input. To get the two's complement of the second operand, the carry input is always a 1 (borrow input=0). For an 8-bit zero, that gives you x - 00000000 ==> x + 11111111 + 1 ==> x + 100000000 (carry output=1, borrow output=0). No special treatment for zero.