# Computer Science Project

Part-1:

Write an ARM assembly code to implement a loop for calculating factorial of an integer

N. For example if the input N from the standard input is equal to 5, it should return 120

(i.e, 5! ); the result (i.e, 120) should be printed on the standard output.

Part-2:

1. Repeat part-1 for N factorial, by adding code to measure program execution time in

milliseconds. This can be achieved by reading system time and storing it into a General

Purpose Register (GPR), or preferably in memory location, and before the program exits

read system time again the difference is the time elapsed for execution. Write the elapsed

time in the output file on the same line as the factorial number in tabular form. Example:

Number Factorial Time elapsed (ms)

———- ———– ———————-

5 120 351

Once you have your program working and creating the proper out file as shown in the

example above, move to next step.

2. Repeat step 1 using by having the following numbers in your input file to calculate their

factorial and the output file must have one entry for each number as shown in the

example table in previous step. The numbers to use in your input file are:

0, 1, 3, 5, 5, 7, 8, 9, 10, 11, 12

Part-3:

1. Open another input file e.g summation-input that contains list of integers, do summation

for each integer (use loops as you did in Project 1). For each summation measure

program execution time, also measure the whole list integers summation time in

milliseconds. This can be achieved by reading system time and storing it into two

different General Purpose Registers (GPRs), or preferably in memory locations, and after

each integer summation read system time again the difference is the time elapsed for

executing that summation. Write the elapsed time in the summation-output file on the

same line as the summation number in tabular form. Example:

Number Summation Time elapsed (ms)

———- ———– ———————-

5 15 201

———————————————————————————————————————

Page 2 of 2

Do step three for all of the following numbers in your summation-input file to calculate

their summation and the summation output file must have one entry for each number as

shown in the example table above, also the last line in the table must have the total

elapsed time for do doing all integer summation using system time. The numbers to use

in your summation input file are:

0, 1, 2000, 4000, 6000, 8000, 10000, 12000, 14000, 16000, 18000, 20000

Note: add appropriate comments to your assembly code explaining what each instruction

does in the context of your program.