I have the following c assembly code which sorts an array in descending order, I have tested it using 8086emu and it worked 100% but at visual studio it gave me wrong results and an error. Any ideas or how to solve this problem.
My Code:-
#include "stdafx.h"
#include <iostream>
using namespace std;
void main(void)
{
short *arr;
arr = new short[10];
cout << "please enter the array elements" << endl;
for (int i = 0; i < 10; i++)
{
    cin >> arr[i];
}
short *p;
p = arr;
_asm{
START:
    mov cx, 9
        mov esi, p
    LABEL2 :
    MOV ax, [esi]
        CMP ax, [esi + 2]
        JGE LABEL1
        MOV bx, [esi + 2]
        MOV word ptr[esi], bx
        MOV word ptr[esi + 2], ax
        JMP START
    LABEL1 :
    inc esi
        inc esi
        LOOP LABEL2
}
for (int i = 0; i < 10; i++)
{
    cout << arr[i] << endl;
}
}

 
     
    