I am attempting to reverse an array2 however my program seg faults and ends right atmov eax, dword [edi]
. theoretically this should work just fine. please any insight or alternative method/recommendations, my professor and pupils are equally stumped. Anything is much appreciated, this is my code:
global _start:
section .bss
section .data
array dd 1,2,3,4,5
array2 dd 1,2,3,4,5
section .text
global _start:
_start:
;first element in array
mov esi, dword [array2]
;second element in array
mov edi, dword [array+16]
;counter reg
mov ecx, edi
;dec edi
call reverseloop
exit:
nop
mov eax, 1
mov ebx, 0
int 80H
reverseloop:
mov eax, dword [edi]
mov ebx, dword [esi]
;swap elements
mov dword [edi], eax
mov dword [esi], ebx
add esi, 4
sub edi, 4
cmp esi, edi
jb reverseloop
ret