Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

convert this 1D stencil C program to RISC v #include #include int main(void) { int randArray[100],stencilArray[100],i; for(i=0;i <100;i++) randArray[i]=rand(); printf( Integers:); for(i=0;i <100;i++) { printf(

convert this 1D stencil C program to RISC v

#include

#include

int main(void)

{

int randArray[100],stencilArray[100],i;

for(i=0;i<100;i++)

randArray[i]=rand();

printf(" Integers:");

for(i=0;i<100;i++)

{

printf(" Integer %d:%d",i+1,randArray[i]);

}

for (i =0; i < 100 ; ++i )

{

stencilArray[i] = 0.25f * stencilArray[i-1] + 0.50f * stencilArray[i] + 0.25f * stencilArray[i+1];

}

printf(" 1D Stencil of the random array:");

for(i=0;i<100;i++)

{

printf(" %d:%d",i+1,stencilArray[i]);

}

return 0;

}

RISCV

.data

sum: .ascii "Sum= "

.text

main:

andi t0, t0,0#initialize t0

andi t1, t1,0#initialize t1 to 0 which holds the sum

andi t2,t2,0#initialize t2 to 0

addi t0,t0,1#load first number

addi t2, t2,101#load the upper limit

loop:

beq t0,t2,end#if t0= 101,then jump to end

add t1,t1,t0#else add it up

addi t0,t0,1#increment the number

j loop#repeat

end:

la a0,sum#load address of message string

li a7,4#display string

ecall

add a0,zero,t1#load sum to a0 for displaying

li a7,1#display integer

ecall

li a7,10#end of the program/termination

ecall

Write Python program to check a list is empty or not

Python class named Circle constructed by a radius and two methods

which will compute the area and the perimeter of a circle.

Write Python program to calculate the area of a trapezoid.

Describe the model for handling graphical output and interactive input in the Abstract Windowing Toolkit (AWT) for Java

Python program to count the frequency of words in a file.

Write python program to print sum of two numbers taken from the user input ?

Write program that reads in Python source code file and counts the occurrence of each keyword and each identifier in the file using two dictionaries:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions