title: How to access an integer in an array in assembly with pointer?
body: <p>First of all, this is a homework assignment. I was told to create a sorting function with these parameters using push and pop. They are passed in the function like this, and I don't know how to access the elements in it with "int *list". I'm in the middle of the process</p>
  
  <pre><code>    int sorter (int* list, int count, int opcode)
      {
      __asm
      {
     mov eax, 0; zero out the result
     mov ebx, opcode; move opcode to ebx for comparison
     ; fill in your code here
     mov ecx, 0; set the counter to 0
     cmp ebx, 0x01; check ascendant or descendant
     je ASCENDANT
     jne DESCENDANT
     ASCENDANT:
     loop_start :
     cmp ecx, count; condition for the outer loop
     jge loop_end
     push ecx
     mov eax,
     }
     }
  
  
  
   loop_start:
     cmp ecx, count   ; condition for the outer loop
     jge loop_end     ; jump if end of array
     mov esi, list    ; move pointer to esi
     mov eax, [esi + 4 * ecx] ; move data that current index to eax
     push ecx         ; push ecx to the stack to save the index
     inner_loop:
       inc ecx        ; increment eax
       cmp eax, [esi + 4 * ecx]; compare eax with the next element in the array
       jle swap       ; if it is less than the current value than jump to swap
       cmp ecx, count ; check if ecx reaches the end of array
       jle inner_loop ; if not than go back to inner loop
       pop ecx        ; it ecx reaches the end than pop eax to go back to the old index of outer loop
       mov[esi + 4 * ecx], eax ; exchange the value of current eax to the element that is compared
       inc ecx        ; increment ecx for outer loop
       jmp loop_start ; jump back to loop start
       swap:          ; swap the smaller value with the current value
       mov eax, [esi + 4 * ecx] ; swapping
     jmp inner_loop   ; jump back to inner loop
   loop_end:
   ret
  </code></pre>