Quick question, I am reading the textbook entitled "Introduction to 80x86 Assembly Language and Computer Architecture" by Richard C. Detmer and on page 21 and 22 it talks about the concept of what a borrow is, but it doesnt really describe what it really is. Here is the text:
In a computer, subtraction a - b of numbers a and b is usually performed by taking the 2's complement of b and adding the result to a. This corresponds to adding the negation of b. For example, for the decimal subtraction 195 - 618 = -423,
00C3 - 026A
is changed to addition of FD96, the 2's complement of 026A.
00C3 + FD96 = FE59
The hex digits FE59 represent -423. Looking at the previous addition in binary, you have
0000 0000 1100 0011 + 1111 1101 1001 0110 = 1111 1110 0101 1001
Notice that there was no carry in the addition. However, this subtraction did involve a borrow. A borrow occurs in the subtraction a - b when b is larger than a as unsigned numbers. Computer hardware can detect a borrow in subtraction by looking at whether a carry occurred in the corresponding addition. If there is no carry in the addition, then there is a borrow in the subtraction. If there is a carry in the addition, then there is no borrow in the subtraction. (Remember that "carry" by itself means "carry out.")
Here is one more example. Doing the decimal subtraction 985 - 411 = 574 using word-length 2's complement representations,
03D9 - 019B
is changed to addition of FE65, the 2's complement of 019B.
03D9 + FE65 = 1023E
0000 0011 1101 1001 + 1111 1110 0110 0101 = 1 0000 0010 0011 1110
Discarding the extra 1, the hex digits 023E represent 574. This addition has a carry, so there is no borrow in the corresponding subtract.
What really is a borrow with subtraction? I thought when for example 00C3 - 026A, the A is bigger than the 3, so we must "borrow" from the corresponding C by making it a B and making it now 13 (base 16) minus A. That we can do, but a "borrow" occured. In this particular example a borrow in the contexts of the book did occur. But when we look at the next example they gave us 03D9 - 019B, the B is bigger than the 9 so we must "borrow" from the D by making it a C and making the 9 a 19 (base 16) minus B. That we can do, and a "borrow" occured but the book stated that a borrow did not happen.
What is a borrow? I know you know if one occurred by whether a carry happened in the addition but doing raw subtraction, what is really a borrow. When can I identify if one occurred?
For example you know a carry occurred because there is an extra hex digit. The length went out of the length of your two hex numbers (length desired to stay within).
Thank you.
-Dan