title: Problem transferring array to register in x86 assembly
body: <p>I am able to assembly, but when I step through with gdb, it crashes when I try to mov the value in the array to the register</p>
  <p>I am assembling with <code>nasm -f elf32 test.asm</code>
  And I am linking with <code>ld -m elf_i386 test.o</code></p>
  <pre><code>section data
      list:
          dw 7, 9, 3, 0
  section text
  global    _start
            _start:
          
  push ebp                               ; prologue
  mov ebp, esp                           ; prologue
  
          mov edx, 1                     ; i = 1
          mov ecx, [edx * 4 + list]      ; ecx = list[i]
  
          loop:
          mov ebx, [edx * 4 + list]
          cmp ebx,0                      ; if (list[i] = 0)
          jz end                         ; exit loop
          cmp ecx,ebx                    ; ecx - list[i]
          jl if_greater                  ; ecx - list[i] = &lt;0
          inc edx                        ; i++
          jmp loop
          
          if_greater:                    ; if condition block
          mov ecx, [edx * 4 + list]      ; new highest value
          inc edx                        ; i++
          jmp loop
  
          end: 
  
          mov esp, ebp                  ; epilogue
          pop ebp                       ; epilogue
  </code></pre>
  <p>I have added updated code. I left the original code. My goal now is to find the highest pair in list, but am unsuccessful.</p>
  <pre><code>
  section data
      list:
          dw 7, 9, 3, 0
  section text
  global    _start
            _start:
          
  push ebp                               ; prologue
  mov ebp, esp                           ; prologue
  
          mov edx, 1                     ; i = 1
          mov ecx, [edx * 4 + list]      ; ecx = list[i]
  
          loop:
          mov ebx, [edx * 4 + list]
          cmp ebx,0                      ; if (list[i] = 0)
          jz end                         ; exit loop
          cmp ecx,ebx                    ; ecx - list[i]
          jl if_greater                  ; ecx - list[i] = &lt;0
          inc edx                        ; i++
          jmp loop
          
          if_greater:                    ; if condition block
          mov ecx, [edx * 4 + list]      ; new highest value
          inc edx                        ; i++
          jmp loop
  
          end: 
          mov eax, 1
          xor ebx, ebx
          int 0x80
  
          mov esp, ebp                  ; epilogue
          pop ebp                       ; epilogue
  </code></pre>
  <p>update 2: I have deleted both the prologue and the epilogue. I also changed <code>edx</code> to 0</p>
  <pre><code>
  section data
      list:
          dd 7, 9, 3, 0
  section text
  global    _start
            _start:
          
  
          mov edx, 0                     ; i = 0
          mov ecx, [edx * 4 + list]      ; ecx = list[i]
  
          loop:
          mov ebx, [edx * 4 + list]
          cmp ebx,0                      ; if (list[i] = 0)
          jz end                         ; exit loop
          cmp ecx,ebx                    ; ecx - list[i]
          jl if_greater                  ; ecx - list[i] = &lt;0
          inc edx                        ; i++
          jmp loop
          
          if_greater:                    ; if condition block
          mov ecx, [edx * 4 + list]      ; new highest value
          inc edx                        ; i++
          jmp loop
  
          end: 
          mov eax, 1
          xor ebx, ebx
          int 0x80
  
  </code></pre>