rendered paste body #Algorithme de Tri par Selection du Minimum
# JSR 2008
.global _tri_min
.section .data
#t: .int #(int t[],size_t size)
#size: .int
#i: .int #int i,j,min,ech;
#j: .int
#min: .int
#ech: .int
t: .int
#t => 8(%ebp) => t:
#size => 12(%ebp)
#i => %eax
#j => %ebx
#min => %ecx
#ech => pile
#variable du à l'asm:
#tmp => %edx
.section .text
_tri_min: #void tri_min(int t[],size_t size)
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax #essai bidon
movl %eax,t #essai bidon
#{
movl $0,%eax #for (i=0;i<size;i++)
for1: #{
cmpl %eax,12(%ebp)
jge end1
movl %eax,%ecx #min = i;
movl %eax,%ebx #for (j=i;j<size;j++)
for2: #{
cmpl %ebx,12(%ebp)
jge end2
movl t(%ebx),%edx #if (t[j] < t[min]) { (t[j])
cmpl %edx,t(%ecx)
jge fincomp
mov %ebx,%ecx #min = j;
fincomp: #}
incl %ebx
jmp for2 #}
end2:
pushl t(%ecx) #ech = t[min];
movl t(%eax),%edx #t[min] = t[i]; (t[i])
movl %edx,t(%ecx) #(t[min =)
popl t(%eax) #t[i] = ech;
incl %eax
jmp for1 #}
end1:
leave
ret #}