   .text
   .align   2
rangeSum:
   str  lr, [sp, #-4]! @ Save lr to stack
   str  fp, [sp, #-4]! @ Save fp to stack
   mov  fp, sp         @ Point fp to bottom of new frame
   sub  sp, sp, #12    @ Reserve 3 words of frame space
   str  r0, [fp, #-8]  @ First param second from TOS
   str  r1, [fp, #-12] @ Second param at TOS
   mov  r3, #0         @ sum = 0
   str  r3, [fp, #-4]  @ sum third from TOS
   b   .L2
.L3:
   ldr  r3, [fp, #-8]  @ r3 = lo
   add  r2, r3, #1     @ r2 = lo+1
   str  r2, [fp, #-8]  @ lo = lo+1
   ldr  r2, [fp, #-4]  @ r2 = sum
   add  r3, r2, r3     @ sum = sum + lo 
   str  r3, [fp, #-4]  @ Copy back to frame
.L2:
   ldr  r2, [fp, #-8]  @ r2 = lo
   ldr  r3, [fp, #-12] @ r3 = hi
   cmp  r2, r3         @ if r2 < r3
   blt  .L3            @   loop again

   ldr   r0, [fp, #-4]  @ Return value in R0
   mov   sp, fp         @ Pop off local vars
   ldr   fp, [sp], #4   @ Restore fp to old val, and reduce sp
   ldr   pc, [sp], #4   @ Back to caller

   .section   .rodata
   .align   2
.LC0:
   .ascii   "Total is %d\012\000"
   .text
   .align   2
   .global   main

main:
	str	lr, [sp, #-4]!  @ Save lr to stack
	str	fp, [sp, #-4]!  @ Save fp to stack
	mov	fp, sp          @ Point fp to bottom of new frame
	sub	sp, sp, #4      @ Reserve one word of space for total
	mov	r0, #10
	mov	r1, #20
	bl	rangeSum
   str   r0, [fp, #-4]   @ Store total into frame

	ldr	r0, .L6         @ R0 gets address of format string
	ldr	r1, [fp, #-4]   @ R1 gets total
	bl	printf

   mov   r0, #0          @ Return 0 from main
	mov	sp, fp          @ Pop off local var total
	ldr	fp, [sp], #4    @ Restore fp to old val, and reduce sp
	ldr	pc, [sp], #4    @ Back to compiler-provided caller

	.align	2
.L6:
	.word	.LC0
