Question: Write a program in ARM assembly language (which can be executed on ARMSim simulator) to calculate sum and mean of a series of integer numbers.
Write a program in ARM assembly language (which can be executed on ARMSim simulator) to calculate sum and mean of a series of integer numbers. Series of integer numbers are stored in a file named input.txt. Input file contains 0 or more integer numbers (see the sample file on Moodle). Your program should open the file for reading, read each of the numbers, calculate sum and mean. It should display the result using standard output. You may use the following subroutine to perform the division.
; R1 - dividend ; R2 - divisor ; R3 - quotient ; R4 - remainder ; if divisor is 0 then it will return 0 in R3 and R4
divider:
mov R3,#0 ; Initialize quotient to 0 mov R4,#0 ; Initialize remainder to 0 cmp R2,#0 ; Branch if divisor is 0 beq done
loop: cmp R1,R2 ; Compare divisor and dividend BLT endloop ; Branch if dividend is < divisor sub R1,R1,R2 ; Subtract divisor from dividend add R3,R3,#1 ; Increment quotient B loop ; Branch to top of the loop endloop: mov R4,R1 ; Move remainder to R4
done: mov pc,lr ; Return to the calling method The above subroutine returns a quotient and remainder. You can ignore the remainder and
display the quotient as the mean of the given numbers.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
