title: What is a borrow in hexadecimal subtraction? (Assembly)
body: <p>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:</p>
  
  <blockquote>
    <p>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,</p>
    
    <p>00C3 - 026A</p>
    
    <p>is changed to addition of FD96, the 2's complement of 026A.</p>
    
    <p>00C3 + FD96 = FE59</p>
    
    <p>The hex digits FE59 represent -423. Looking at the previous addition in binary, you have</p>
    
    <p>0000 0000 1100 0011 + 1111 1101 1001 0110 = 1111 1110 0101 1001</p>
    
    <p>Notice that there was no carry in the addition. However, this subtraction did involve a <strong>borrow</strong>. A <strong>borrow</strong> 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 <strong>borrow</strong> in the subtraction. If there is a carry in the addition, then there is no <strong>borrow</strong> in the subtraction. (Remember that "carry" by itself means "carry out.")</p>
    
    <p>Here is one more example. Doing the decimal subtraction 985 - 411 = 574 using word-length 2's complement representations,</p>
    
    <p>03D9 - 019B</p>
    
    <p>is changed to addition of FE65, the 2's complement of 019B.</p>
    
    <p>03D9 + FE65 = 1023E </p>
    
    <p>0000 0011 1101 1001 + 1111 1110 0110 0101 = 1 0000 0010 0011 1110</p>
    
    <p>Discarding the extra 1, the hex digits 023E represent 574. This addition has a carry, so there is no borrow in the corresponding subtract.</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>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). </p>
  
  <p>Thank you.</p>
  
  <p>-Dan</p>