Skip to main content

Subtract two 16-bit numbers

Subtract two 16-bit numbers

  1. LHLD 2500H      : "Get first 16-bit number in HL"  
  2. XCHG            : "Save first 16-bit number in DE"  
  3. LHLD 2502H      : "Get second 16-bit number in HL"  
  4. MOV A, E        : "Get lower byte of the first number"  
  5. SUB L           : "Subtract lower byte of the second number"  
  6. MOV L, A        : "Store the result in L register"  
  7. MOV A, D        : "Get higher byte of the first number"  
  8. SBB H           : "Subtract higher byte of second number with borrow"  
  9. MOV H, A        : "Store l6-bit result in memory locations 2504H and 2505H"  
  10. SHLD 2504H      : "Store l6-bit result in memory locations 2504H and 2505H"  
  11. HLT             : "Terminate program execution" 

Comments