#define ASM
#include "tab.h"

                     .global  t
                     .global  somme
                     .global  f

                     .bss
t:                   .skip  MAX*4
somme:               .skip  4

                     .text

@ r0 : i,  r1 : s,  r2 : i*sizeof(unsigned int) r3 : t  r4 : tmp

f:                   stmfd  sp!,{r0-r4}

                     mov   r1,#0             @ s=0
for:                 mov   r0,#0             @ i=0
                     b     testfor           @ goto test_for
corpsfor:            ldr   r3,= t            @ s = s + t[i]
                     mov   r2,r0, LSL #2     @ i*sizeof(unsigned int)
                     ldr   r4, [r3,r2]       
                     add   r1,r1,r4
                     add   r0,r0,#1          @ i++
testfor:             cmp   r0,#MAX           @ if (i<MAX) goto corpsfor
                     blo   corpsfor
finfor:
                     ldr   r4,= somme        @ somme = s;
                     str   r1,[r4]

                     ldmfd  sp!,{r0-r4}
                     mov   pc,lr

                     .ltorg
