Please help me find the error with my code. Whenever I try to run the program, it returns a Segmentation Fault message. I've been trying to find and play with the codes but I'm really stuck.. Please help me.. Here's my code:
.section .data
format:
.asciz "%d\n"
values:
.int 5, 3, 2, 4, 7
smallest:
.int 0
.section .text
.global _start
_start:
leal values(, %edi,4), %esi
movl $4, %ecx #outer loop counter
movl $4, %ebx #inner loop counter
movl (%esi), %eax
movl %eax, smallest
addl $4, %esi
dec %ebx
jz output
loop:
movl (%esi), %eax
cmp smallest, %eax
jl minimum
jmp converge
minimum:
movl %eax, smallest
converge:
dec %ebx
addl $4, %esi
jnz loop
dec %ecx
jz output
addl $1, %edi
leal values(, %edi,4), %esi
jmp loop
output:
addl $0, %edi
output_loop:
movl values(, %edi, 4), %eax
push %eax
push $format
call printf
addl $8, %esp
cmp $4, %edi
je end
addl $1, %edi
loop output_loop
end:
movl $1, %eax
movl $0, %ebx
int $0x80
Thanks in advance!