Question: Part 1 : Coding task - Average Absolute Deviation of an Array of Numbers Task: Write a short assembly program that finds the average absolute

Part 1: Coding task - Average Absolute Deviation of an Array of Numbers
Task: Write a short assembly program that finds the average absolute deviation (of a given
array. You are given an array with elements {x1,x2,x3,dots,xn} and your code computes
1ni=1n|xi-(x)|
where x=1ni=1nxi is the mean value of the elements.
The average absolute deviation is a measure of the statistical dispersion of a set of given
samples. The standard deviation, defined as the square root of the variance, is another widely
used measure of statistical dispersion but requires multiplication and taking square roots to
compute. The average absolute deviation is easier to compute and more suitable for
microcontroller applications with a limited instruction set.
Note that, in most cases, the computed average absolute deviation will only be an
approximation due to limitations of available operations. Recall that there is no instruction to do
division unless we are dividing by a power of two. Even then, we will make rounding errors if the
outcome of the division is not an integer value.
For this assignment, you do not need to worry about approximation errors. You will work on a
set with 16 numbers to facilitate easy division (you know how to divide by 16) and you can
neglect rounding errors due to discarded fractional bits (do not attempt to fix rounding errors).
.data ; Assemble into RAM
.retain ; Override ELF conditional linking
.retainrefs ; And retain any sections that have
samples: .word 45,76,11,23,49,91,43,17,71,27,63,41,34,83,67,59
LENGTH: .set 2*16
buff: .word 0x8000
mean: .word 0 ; Your code will return the mean here
aad: .word 0 ; Your code will return the avg. absolute deviation here
foot: .word 0x7FFF
24
25; Do NOT modify any of these definition for your submission
26; You can experiment while debugging, but submit your results for the given set
27;
Your code needs to follow all these requirements or constraints:
Your code needs to compute the mean value of the samples in mean.
Your code needs to compute the average absolute deviation of the samples in aad.
Your code is not allowed to modify the RAM or FRAM otherwise. That means
Your code is not allowed to modify the samples, buff, or foot.
Your code is not allowed to create new variables, arrays etc. in RAM or FRAM (nor
does it need to).
Your code needs to use indexed mode with the label samples when accessing the
elements in the given array and use the constant LENGTH instead of hardcoded values.
(This is a good restriction since using indexed mode will actually make your life easier.)
Your code is allowed to use core registers as needed.
Your code must not be wasteful with resources.
Your code must not use more core registers than necessary.
Your code must not use unnecessary jumps (aka no spaghetti).
Your code must not have unnecessary instructions and the like.
You code should have comments and use descriptive labels.
Part 1 : Coding task - Average Absolute Deviation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!