Write a program to add all the odd numbers from 1 to n The v
Write a program to add all the odd numbers from 1 to n. The value of n will be in R_5. The result of the additions will be in R_0. raw the Flow chart of your program. Write a complete ARM Cortex-M_4 assembly language program to sum up all the odd number up to the value in R_5. Remember the final sum should be left in R_0. The program should work for ANY reasonable value in R_5. Example 1: If the value in R_5 = 10. R_0 = 1+3+5+7+9 (sum of all the odd numbers) Example 2: If the value in R_5 = 11. R_0 = 1+3+5+7+9+11 (sum of all the odd numbers)
Solution
Value 1 = value to be loaded (entered)
value 2 = 02
value 3 = 00
value 4 = 01
LDR R5, value1
LDR R4, value 2
LDR R3,value 4
LDR R0, value3
CMP R0,R5
BEQ Looptest
ADD R0,R0,R3
Looptest : CMP R0,R5
BHE Done
Done: STR R0,RESULT
SWI &11
