Click here to Skip to main content
15,879,490 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Create an assembly language program that will have two arrays, of five elements each.
Sum the corresponding elements in the two arrays together and store the result in the ‘a’ array. Do this
for each element. In other words:
a[0] = a[0] + b[0]
a[1] = a[1] + b[1]
a[2] = a[2] + b[2]
a[3] = a[3] + b[3]
a[4] = a[4] + b[4]

You must use one register to load the ‘a’ values into and one register to load the ‘b’ values into. And you
must use a loop to load and add together each pair of ‘a’ and ‘b’ values.
When this is complete, add together all of the values in the ‘a’ array, and store that value in memory.
The values in each array at the start should be: 1, 2, 3, 4, 5:
a[0] = b[0] = 1
a[1] = b[1] = 2
a[2] = b[2] = 3
a[3] = b[3] = 4
a[4] = b[4] = 5

The code that adds the two arrays together and then sums the elements together is to be in a separate
sub-routine.
Do not use any synthetic instructions.

What I have tried:

Ive tried a few things but at this point I think I have confused myself
Posted
Updated 1-Apr-21 8:52am
v2
Comments
SeanChupas 1-Apr-21 13:54pm    
Step 1, unconfuse thyself. You can't solve a problem you do not understand.
Step 2, write out what you need to do in English and then translate that into Assembly.

It's unlikely that anyone here will do all of this for you so I'd suggest asking something more specific.
honey the codewitch 2-Apr-21 3:19am    
Prototype it in C and then simply spit the asm out using the compiler.

There's hardly any reason to use an assembler directly anymore, and many good reasons not to, but if you *must* use an assembler, use C or C++ to prototype your assembly code where you can.

The above can easily be written in C, so write it in C, and then use your favorite C compiler to get the assembly from it, and then look at that.

You haven't specified which assembly you want. Are you coding for an ATmega2560, a Tensilica, an ARM, x86?

Don't bother. Just use C and get asm that way. If you want to tune it from there you can.

1 solution

The same way you would in a high level language.

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
The process is the same in all languages, including assembler!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900