Computer Science Code in RISC-V Assembly language Question, I want Answer

Job ID: 31964551

Budget: ₹600 – ₹1,500 INR

Code in RISC-V Assembly language

Count the number of times an element appeared in the array

File: count_target.s
For this part, any use of the term “integer” refers to a 32-bit, signed integer.
Write a program that counts the number of times that a target integer (given in a variable target) appears in an array of
integers called arr whose length is given in a variable called arrlen. The final count should be placed in a variable count that
will already be defined in the input file.
Your program should be written in a file called count_target.s. You should start with the skeleton version that looks as follows:
1 .text
2
3 .global main
4 main:
5
4Here, by “compiler”, we mean the program that does the step of converting source code to assembly code.
6

6 # YOU SHOULD NOT ADD ANY CODE PAST THIS POINT.
7 end:
8 j end
9 .end

The first – input_count_target1.s – is shown below. (As a reminder, you would want to rename this to
input_count_target.s in order to use it with the provided makefile as is.) The number of times that 13 appears in arr is 3, so
your program should set the count variable to 3. Your program should not assume (or care about) the initial value of count.
1 .data
2
3 .global arr , arrlen , target , count
4 arr:
5 .word 5, 13, -8, 19, 20, 13, 5, 13
6 arrlen:
7 .word 8
8 target:
9 .word 13
10 count:
11 .word -1
The second example – input_count_target2.s – is shown below. With this input, the count variable should be
set to 2 by your program.
1 .data
2
3 .global arr , arrlen , target , count
4 arr:
5 .word 19, 20, 14, 19, 15
6 arrlen:
7 .word 5
8 target:
9 .word 19
10 count:
11 .word -1
Here, you will have to load the array length from the arrlen variable
instead

The skeleton code is given as follows :-

.text

.global main
main:

# YOU SHOULD NOT ADD ANY CODE PAST THIS POINT.
end:
j end
.end
My stats
Today
CF Score:
N/A
Related categories: C Programming Assembly Computer Science