You are on page 1of 9

OUTPUT FOR ADDITION OF FOUR NUMBERS:

Ex.No:2
Date:
ARRAY ADDITION
AIM:
To write an ARM Cortex – M4 assembly language program to perform the following:
(i) Addition of 4 numbers
(ii) Array addition

SOFTWARE REQUIRED:
Keil MDK ARM vision5 Compiler.

ALGORITHM FOR ADDITION OF FOUR NUMBERS:


1. Start the program.
2. Get the input data’s in X1, X2, X3, and X4.
3. Load the X1, X2, X3 and X4 values in corresponding data registers r0,r1,r2,r3.
4. Perform the addition of four numbers.
5. Store the result in data register r0.
6. Stop the program.
CODING:
ALGORITHM FOR ADDITION OF N NUMBERS:

1. Start the program.


2. Globally initialize (in data area) the Array variable for input data items, count variable (N)
and result variable to zero.
3. Move 00h to the data register R0.
4. Load the starting address of array to the data register R 1
5. Load the starting address of N to the data register R2.
6. Load the content of R1 to data reregister R3.
7. Add the contents of R0 and R3 registers and store the result in R0.
8. Add the contents of R1 with immediate data #04h to point the next data in the array
9. Subtract the contents of R2 by immediate data #01h and store the result in R 2.
10. If result is not equal, then go to step7 (using BNE instruction) else store the result in data
register R4 and stop the program.
OUTPUT FOR ADDITION OF N NUMBERS:
CODING:
RESULT:
Thus ARM Cortex – M4 ALP to perform Addition of 4 numbers and addition of n numbers
are successfully executed and their results are verified using KEIL uvision5 IDE.

You might also like