MIDA = 100
.data
v: .int -7, 7, -1, 32, 45, 0 # Acabat en 0
sp: .asciz "El valor %d és positiu\n"
sn: .asciz "El valor %d és negatiu\n"
.text
.global main
main:
 movl $0, %ecx
for:
 cmpl $0, v(,%ecx,4)
 je endfor
 pushl %ecx
 pushl v(,%ecx,4)
 call signe
 addl $4, %esp	# 13
 pushl v(,%ecx,4)
 cmpl $1, %eax	# 12
 jne else
 pushl $sp
 jmp endif
else:
 pushl $sn
endif:
 call printf
 addl $8, %esp
 popl %ecx
 incl %ecx
 jmp for
endfor:

 movl $0, %ebx
 movl $1, %eax
 int $0x80

signe:
 pushl %ebp
 movl %esp, %ebp
 movl 8(%ebp), %eax
 cmpl $0, %eax
 jge signe_else
 movl $0, %eax
 jmp signe_endif
signe_else:
 movl $1, %eax
signe_endif:
 popl %ebp
 ret

# (gdb) break signe
# (gdb) run
# (gdb) x/4xw $ebp-16
# 0xbffff30c:	0x00181235	0x0011f270	0x00000000	0x08048459
# (gdb) x/4xw $ebp
# 0xbffff31c:	0x00000000	0x08048400	0xfffffff9	0x00000000
# # #             (%ebp)          4(%ebp)         8(%ebp)         12(%ebp)
# # #             old_ebp         %eip/@ret       v(,%ecx,4) =-7  %exc = 0
# (gdb) x/4xw $ebp+16
# 0xbffff32c:	0x001674d3	0x00000001	0xbffff3c4	0xbffff3cc

