Question
Program with the Y86 Assembly language and add comments to code. At the Linux command line prompt: % yas lab4.ys Be sure to include comments
Program with the Y86 Assembly language and add comments to code.
At the Linux command line prompt:
% yas lab4.ys
Be sure to include comments in the code documenting what the code does, and pay attention to formatting to make sure the code is as clear as possible, and easy for a reader of your program to understand.
GRADING CRITERIA (approximate percentages listed)
(10%) The code and algorithm are well commented.
A comment should be included in the main program including the programmer name(s) as well as explaining the nature of the problem and an overall method of the solution (what you are doing, not how).
A short comment should be included for each logical or syntactic block of statements, including each function.
(90%) The results are correct, verifiable, and well?formatted. The program correctly performs as assigned.
LAB DESCRIPTION:
CREATE A Y86 ASSEMBLY LANGUAGE PROGRAM THAT WILL COUNT THE NUMBER OF ELEMENTS IN AN ARRAY, WILL FIND THE MIN ELEMENT OF THE ARRAY, WRITE A SECOND ARARY WITH ALL ELEMENTS REVERSED AND WRITE TO OUTPUT THE SUMS OF THE ARRAY WITH THE COORESPONDING ELEMENT OF THE SECOND ARRAY.
Mandatory filename: lab4.ys
PROBLEM:
Write an assembly language program with five procedures using Y86. The program should have an input array, defined at the top of the program, with an indeterminate number of values (but no more than 25), which appear in unsorted order. The program will need a Main procedure, a Count procedure, to determine the number of values in the input array, a Min procedure, to find the minimum value in the array, a Max procedure, to find the maximum value in the array, and a Reverse procedure, which will write the values in the input array to output in reverse order.
You are required to define the following at the top of your program:
An input array label, Array; put this label at address 0x300.
The actual array values(see below for sample input)
A label at the end of the input array, Done, with no data value (that is, the label only)
A label for a second array, RArray; put this label at address 0x400
An output label, Output; put this label at address 0x500
A stack label, Stack, at a high enough address so that the stack will not grow into the output data, the input data, or the code; put this label at address 0xf00.
Example input, and memory for output and stack: #Use appropriate .pos and .align directives here
Array:
.quad 12
.quad ?2
.quad 16
.quad ?10
.quad 13
.quad ?27
.quad 10
Done:
#Use appropriate .pos and .align directives here
RArray:
#Use appropriate .pos and .align directives here
Output:
#Use appropriate .pos and .align directives here
Stack:
INPUT:
There are no data errors that need to be checked as all the data will be assumed correct. You can assume that the values in the input array are signed integers, which may be negative, positive, or zero.
Your program should be able to handle an unknown number of array values(some number between 1 and 25) and still work. That is, you cannot assume that you know how many input values there will be. The grader will change the number of input values in the input array, and the values themselves, to test your program.
You must use the Done label at the end of the input to detect the end of the input array to calculate Count.
You should not change the names of the labels, but you can use any addresses you wish, as long as your program executes correctly, although the addresses given above will definitely work.
CONSTRAINTS:
Your program must have five procedures, with the labels Main, Count, Min, Reverse and Add.
You need to write the Main procedure to call the other four procedures at appropriate points, and with the appropriate parameters in registers to pass to the procedures, so that they do what is described below. You are allowed to do other work in Main to manipulate parameter values to pass to the procedures before you call them. Main should also write the values returned by Count and Min to output. Reverse will write to the RArray and Add will write its output directly to output without returning it to Main.
The Count procedure should determine the number of values in the input array, and return this value to Main. Main will then write the value to output. This value should be in the first memory location in the output. Count should be passed exactly two parameters, namely, a pointer to Array, and the address of the Done label. A C? language prototype of this procedure might look like:
long Count(long *Array, long *Done);
The Min procedure should find the minimum value in the input array and return this value to Main. Main will then write the value to output. This value should be in the second memory location in the output. Min should be passed exactly two parameters, namely, a pointer to Array, and the number of values in Array. A C? language prototype of this procedure might look like:
long Min(long *Array, long Count);
The Reverse procedure should:
o write the values in the input array to RArray in reverse order, i.e., from the last value in the input array to the first.
o Reverse should be passed three parameters: a pointer to Array, Count, and a pointer to RArray. A C?language prototype of this procedure might look like:
void Reverse(long *Array, long Count, long *RArray);
o You cannot access the Done label or its address from Reverse procedure. You cannot print the values in reverse by pushing all of them onto the stack and then popping them off one by one and writing them to output.
The Add procedure should add the first element of Array to the first element of RArray and print the sum to the next location in the output. Add should be passed four parameters, a pointer to Array, Count, a pointer to RArray, and the next valid address in Output. AC?language prototype of this procedure might look like:
voidAdd(long*Array,longCount,long*RArray, long*Output);
To pass values to procedures, you must use appropriate registers. You cannot use the stack because there are less than 6 parameters being passed.
You should a follow the conventions discussed in the slides for caller save and callee save registers and the register paradigm for passing parameters and a return value between the caller and the callee.
OUTPUT:
You need an output area of memory in your program which is required to be at the top of your program with the descriptive label given above associated with it.
The output is the number of values in the input Array (i.e. Count), the minimum value in the input array, followed by all the sums of the input array and the reverse. A sample yis output will be forthcoming.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started