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 (i.e., array
of 16-bit numbers). The array has 60 elements. Each of these elements is a signed integer
value between -100 and +100(inclusive). You will use indexed mode to access the elements in
the array and find the sum of these 60 elements in R5.
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 ,
100]. No need to create a variable for the sum, you will compute the sum in R5.
Once you have your code ready, you can continue to the next page.
ECE 2560 Intro to Microcontroller-Based Systems
Autumn 2024
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 38,39, and 40.
Main loop here
33
34
clr.le R4
6 add_next:
30;
\
\
37
38
e.39
cmp.\ ## R4
40
jlo add_next
done:
43
nop
Can you fill in the blanks in lines 38 and 39 so that the code adds all 60 numbers in the array
(and no other number).
(a) What is the correct instruction for line 38? Remember to enter the complete mnemonic
including the byte/word indicator .b or .w
Next, we need to fill the blanks in line 39. Can you identify the value(s). 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 39? Enter a decimal number.
(c) What is the largest value that works in line 39? Enter a decimal number.
(d) Is there another correct choice of instruction that works in line 40? Correct means that
the instruction would deliver correct results for any scenario where we are processing
(here adding) all numbers in an array (here 60 elements).
Your task is to write assembly code that adds all

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!