Question: Write the program in RISC V Take input of an integer and output how many times the inputted integer appears in the given array Example

Write the program in RISC V

Take input of an integer and output how many times the inputted integer appears in the given array

Example I/O

Initialized Array in code: 1,4,5,5

User Input: 5

Output: 2

My code so far, you can use if it's useful

ORG 0x100 A: DD 1, 2, 55, 4, 5, 6, 7, 8 ecall x9, x5, 5 ld x31, A+56(x0) addi x6, x0, 0 loop: ld x5, A(x6) bne x9, x5, iterate iterate: addi x6, x6, 8 beq x0, x0, loop addi x10, x10, 1 beq x5, x31, e

e: ecall x0, x10, 0

ebreak x0, x0, 0

d: DM 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!