Question: Your task is to write assembly code that adds all the numbers in a given word array ( i . e . , array of
Your task is to write assembly code that adds all the numbers in a given word array ie array
of bit numbers The array has elements. Each of these elements is a signed integer
value between and inclusive You will use indexed mode to access the elements in
the array and find the sum of these elements in R
This is a great point to stop and write such a program yourself. Define an array in RAM using
assembler directives, you can fill it with signed random integers taking values in the range
No need to create a variable for the sum, you will compute the sum in R
Once you have your code ready, you can continue to the next page.
ECE Intro to MicrocontrollerBased Systems
Autumn
Here is one attempt at the code that does the given task. You can see that the code is not even
compiling due to blanks in lines and
Main loop here
clrle R
addnext:
;
e
cmp ## R
jlo addnext
done:
nop
Can you fill in the blanks in lines and so that the code adds all numbers in the array
and no other number
a What is the correct instruction for line Remember to enter the complete mnemonic
including the byteword indicator b or w
Next, we need to fill the blanks in line Can you identify the values If there is only one
correct value enter the same number in part b and c
b What is the smallest value that works in line Enter a decimal number.
c What is the largest value that works in line Enter a decimal number.
d Is there another correct choice of instruction that works in line Correct means that
the instruction would deliver correct results for any scenario where we are processing
here adding all numbers in an array here elements
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
