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
 cmpl $1, %eax
 jne else
 pushl v(,%ecx,4)
 pushl $sp
 call printf
 addl $8, %esp
 jmp endif
else:
 pushl v(,%ecx,4)
 pushl $sn
 call printf
 addl $8, %esp
endif:
 addl $4, %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

