.pos 0 irmovl stack,%esp # initialisation pile jmp main # appel main() square: mrmovl 4(%esp),%edx # param x rrmovl %edx,%ecx # compteur n = x xorl %eax,%eax # res = 0 loopsq: isubl 1,%ecx # n-- jl endsq # repeter n fois addl %edx,%eax # res += x jmp loopsq endsq: ret # retour dans %eax sum: mrmovl 4(%esp),%ecx # param n mrmovl 8(%esp),%edx # param t irmovl 0,%eax # res = 0 loop: isubl 1,%ecx # n-- jl end # fin si n < 0 mrmovl (%edx),%ebx # x=*t addl %ebx,%eax # res += x iaddl 4,%edx # t += 4 jmp loop end: ret # retour dans %eax main: xorl %eax,%eax # %eax = 0 rmmovl %eax,res # init de res irmovl t,%eax # empiler n et t pushl %eax mrmovl n,%eax pushl %eax call sum # appel sum(n,t) iaddl 8,%esp # depiler n et t rmmovl %eax,res # mise à jour de res halt .pos 0x200 res: .long 0 t: .long 1 .long 2 .long 3 .long 4 n: .long 4 .pos 0x300 stack: