title: performs a recursive binary search on an ordered array
body: <p>I want to write a  subroutine that performs a recursive binary search on an ordered array of 16 bit two's complement words. I have most of the code, all i need to do now is write a recursive binary search subroutine. any help?</p>
  
  <pre><code>int binSearch(int key, int &amp;lo, int &amp;hi) {
      if(hi &lt; lo)
         return NOT_FOUND;  //RETURN with V = 1  
      int mid = (lo+hi) / 2;
      if(key == array[mid])
         return mid;
      else if(key &lt; array[mid]) // go left
         return binSearch(key, lo, mid-1); // left
      else
         return binSearch(key, mid+1, hi); // right
      }
  </code></pre>
  
  <p>Im trying to put that to assembler.</p>
  
  <pre><code>link        A6,#0
      movem.l        D1/A1-A2,-(sp) *this is right
      move.w        8(A6),D1   *key *this is right
      movea.l        10(A6),A1  *lo*this is right
      movea.l        14(A6),A2  *hi*this is right
  
      cmpa.l        A1,A2 *if hi&gt;lo
      BHS            else
      move.l        A1,D1 *low D1
      add.l        A2,D1 *adds hi
      asr.l        #1,D1 * divide by 2
      andi.w        #$FFFE,D1 * I dont cras
  </code></pre>
  
  <p>h 
  the part here I have some right, How DO i do  if(hi &lt; lo)</p>