title: CMP and JGE not working in Turbo C++
body: <p>I am working on a Mix program in C++ and Assembly Language(8086) to find smallest number from an array. Here is my code</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;conio.h&gt;
  using namespace std;
  void main()
  {
  __int16 a[5],x,y,res;
  int i,j;
  y=999;
  
  cout&lt;&lt;"\n Enter 5 Numbers:";
  for(i=0;i&lt;5;i++)
  {
      cin&gt;&gt;a[i];
  }
  
  _asm{
      mov bx,y
  }
  
  //Finding smallest
  for(i=0;i&lt;5;i++)
  {
      x=a[i];
      _asm{
          mov ax,x
          cmp ax,bx
          jge nxt
          mov bx,ax
          nxt:
      }
  }
  
  _asm{
      mov res,bx;
  }
  
  cout&lt;&lt;"\n Smallest Element:"&lt;&lt;res;
  getch();
  }
  </code></pre>
  
  <p>The above code is written in Visual Studio 2010 and seems to be working fine. But when I update the same code for Turbo c++ (i.e. changing "iostream" to "iostream.h", removing "using namespace std;", changing "__int16" to "int" etc), it does not work. The answer produced after execution is wrong.</p>
  
  <p>Here is my TC++ program for same</p>
  
  <pre><code>#include&lt;iostream.h&gt;
  #include&lt;conio.h&gt;
  void main()
  {
  int a[5],x,y,res;
  int i,j;
  y=999;
  
  cout&lt;&lt;"\n Enter 5 Numbers:";
  for(i=0;i&lt;5;i++)
  {
      cin&gt;&gt;a[i];
  }
  
  _asm{
      mov bx,y
  }
  
  //Finding smallest
  for(i=0;i&lt;5;i++)
  {
      x=a[i];
      _asm{
          mov ax,x
          cmp ax,bx
          jge nxt
          mov bx,ax
      }
      nxt:
  }
  
  _asm{
      mov res,bx;
  }
  
  cout&lt;&lt;"\n Smallest Element:"&lt;&lt;res;
  getch();
  }
  </code></pre>
  
  <p>Why TC++ and Visual Studio 10 do not give same answer?</p>