Please I will be greatful if someone help me put the program below In assembly language. I have been trying for ages but couldnt get. I found the question in some science website and I have been trying to figure it out but i cant. So please join me in doing this.
The questions...
The goal of this lab is to read a series of numbers from a block of contineous memory, three numbers at a time. Upon obtaining the three numbers, the program will add the three numbers together and store the result back into a second contineous block of memory.
The program flow will look like this:
START (Label)
Call a "function"(1) named "ReadThree" to Read the next three numbers into registers %r1, %r2, and %r3.
The ReadThree function should use a memory label "INPUT", plus an offset that you store in %r10 to load the values. %r10 should be incremented appropriately.
When you have loaded the values into the registers, return using the JMPL command with %r15 as the destination address.
Check to see if all three values (%r1, %r2, and %r3) are ZERO. If they are, go to the label named END.
Call a "function" named "AddThree". This function will add the values in %r1, %r2 and %r3 and store the result in %r4, then return using JMPL.
Call a "function" called "StoreResult". This function will take the value in %r4 and store it in a memory location with the label "OUTPUT", plus an offset that is stored in %r11. %r11 should be incremented appropriately so that the results are stored in sequence in memory. When the output has been stored, the function should return using JMPL and %r15, as appropriate.
END (Label)
Once we come to the end, we should HALT the program.
At the end of the program code (before .end) we will have two sections of memory. One with the label INPUT, the other with the label OUTPUT. The code for this will appear as follows:
INPUT: 10 (2)
10
10
20
20
20
30
30
30
40
40
40
0
0
0
OUTPUT: 0
0
0
0
0
.end
When the program has finsihed running, memory should look like this:
INPUT: 10
10
10
20
20
20
30
30
30
40
40
40
0
0
0
OUTPUT: 30
60
90
120
0
Notes:
(1) They're not TRUE functions, but instead they are memory labels to which we jump and return. That's why I've written them as "function" (in quotes)
(2) This data is sample data only. I will use something sneaky like 0, 1, 2 in the data to see if you are looking for ONE zero in order to quit, or three like instructed. :)