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
	.asciz "%d\n"
	.int 5, 3, 2, 4, 7
	.int 0
.section .text
.global _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
	movl (%esi), %eax
	cmp smallest, %eax
	jl minimum
	jmp converge
	movl %eax, smallest
	dec %ebx
	addl $4, %esi
	jnz loop
	dec %ecx
	jz output
	addl $1, %edi
	leal values(,  %edi,4), %esi
	jmp loop
	addl $0, %edi
	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
	movl $1, %eax
	movl $0, %ebx
	int $0x80

Thanks in advance!

Please forgive me if I am wrong:
I use intel sintax and may be I am wrong.
At this line:
leal values(, %edi,4), %esi
If it translate to intel sintax:
lea esi, [values + edi*4]
Or something like this, you need to realize that "EDI" has a random value.
May be you need to init it.
And at lines:
dec %ebx
addl $4, %esi
jnz loop
You really want to write:
addl $4, %esi
dec %ebx
jnz loop
addl $4, %esi
Changes the flags.
And forgive if I am wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.