.section .text
.global _start

_start:
    mov r0, #10     /* Number of iterations */
    mov r1, #0      /* Sum */
    ldr r2, =0x30008000  /* Memory address to store the sum */
    
    bl calculate_sum  /* Call subroutine to calculate sum */

    /* Store the sum in memory */
    str r1, [r2]

    /* Exit the program */
    mov r0, #0  /* Exit code */
    mov r7, #1  /* sys_exit */
    swi 0       /* Invoke syscall */

/* Subroutine to calculate sum */
calculate_sum:
    push {lr}  /* Save return address */
    
loop1:
    add r1, r1, r0  /* Add current number to sum */
    subs r0, r0, #1 /* Decrement counter */
    bne loop1       /* If counter is not zero, loop */
    
    pop {pc}  /* Return to caller */
