Reference no: EM133626036
IN ASSEMBLY ARMv8 program that computes the histogram of a set of non-negative integers. The input numbers will be specified in double word type in your program and will range between 0 and 100. Your program will count how many times each integer appears in a histogram with 101 bins.
(2) The code must include a procedure for returning the element of a particular rank, e.g. the 8th smallest number. The rank will always be defined starting from the minimum value, and rank 1 corresponds to the smallest element. See the example below.
(3) Optionally, the code can accept a list of ranks and call the procedure multiple times. In this case, the number of ranks to be tested should also be provided in the data section (not shown in example).
(4) The procedures must return correctly to the caller and this must be demonstrated by a printout of the result by the caller.
(5) The code must print the histogram, as well as the values with the ranks specified in the data section using printf as shown below.
The input data and the length of the array will be specified as follows:
.data inpdata: .dword 2, 0, 2, 3, 4, 6 inplen: .dword 6 rank:
.dword 4
The output of the histogram computation should be:
Number:0,1,2,3,4,5,,6 count: 1,0,2,1,1,0,1
The last printed row should correspond to the maximum value found in the data. You can use \t in the printf format string to insert a tab in the output, but ugliness of the printouts will not be penalized.
To find the element with rank equal to 2, we need to look for the histogram bin that includes the second smallest number. This can be found by adding the counts in the bins of the histogram, starting from 0, until we reach or exceed 2. In this example, we need to include bins 0, 1 and 2 to include the second smallest number of the input (in bin 2). Therefore, the element with rank 2 has value equal to 2.
Similarly, to find the element with rank 4, we need to identify the histogram bin that includes the fourth smallest number. To reach it, we need to include bins 0, 1, 2 and 3
Therefore, the element with rank 4 has value equal to 3.
The output of your program should have the following form. Keep in mind that the main function should print the value returned by your procedure.
The value of the rank-4 element is 3
Test your code with data that span the entire range from 0 to 100; that would produce histograms with empty bins; or histograms with one non-empty bin.
Test your rank finder procedure with rank equal to 1, N (the length of the input array), a value in the middle of a bin, and a value at the end of a bin, such as 2 and 3 in the above example.