Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So I need to translate this code from java to a RISC-V simulator. The first picture is of what Im given and where in the

So I need to translate this code from java to a RISC-V simulator. The first picture is of what Im given and where in the buttom The rest of the code goes here is where I should put the translated have code. The second picture is the java code that should be translated to a RISC-V simulator. Please help me with that thank you in advance.
image text in transcribed
image text in transcribed
GLOBAL # Global location of the whole program STACK definition-_mm Oxffffffffffff0000 # The bottom of the stack Oxfffffffffffffff8 # The top of the stack BSTACK: DD TSTACK: DD # HEAP definition BHEAP: THEAP MAL LAST IDX DD DD OxffffOOOOOOOOOOOO # The top of the HEAP DD Oxffffffffffff0000 # The bottom of the HEAP # The last available index in # the heap # Memory allocation -- simple array for the heap representation MALLOC Id x5, x0, MAL LAST IDX # Load the value of the index ld x6, xo, BHEAP # Load the address of the base of the heap add x10 x5x aupc x7, MAL LAST IDX # Loading the address of the index into upper 20 # Calculating the allocated address for returning # bits word # shift to the right by 12 bits to the right # address # make the index always multiple of 4 # Increasing the index # store the new value of index # return to caller srli x7x712 sili x28,x12, 2 add / x5, x5, 28 sdx5 0 (x7 jalr x0 , 0(x1) x5 x5,x28 # START of the application START # Stack pointer Initialization 1dsp,TSTACK (xO) # Global pointer Initialization aupc x3, GLOBAL srli x3, x3, 12 # The rest of the code goes here public class FractionClient public static void main (String[l args) Fraction anew Fraction (3,8); Fraction bnew Fraction (1,2); a.add (b) System. out.print (a.getNumerator ) System.out.print('/") System.out.print (a.getDenominator )) GLOBAL # Global location of the whole program STACK definition-_mm Oxffffffffffff0000 # The bottom of the stack Oxfffffffffffffff8 # The top of the stack BSTACK: DD TSTACK: DD # HEAP definition BHEAP: THEAP MAL LAST IDX DD DD OxffffOOOOOOOOOOOO # The top of the HEAP DD Oxffffffffffff0000 # The bottom of the HEAP # The last available index in # the heap # Memory allocation -- simple array for the heap representation MALLOC Id x5, x0, MAL LAST IDX # Load the value of the index ld x6, xo, BHEAP # Load the address of the base of the heap add x10 x5x aupc x7, MAL LAST IDX # Loading the address of the index into upper 20 # Calculating the allocated address for returning # bits word # shift to the right by 12 bits to the right # address # make the index always multiple of 4 # Increasing the index # store the new value of index # return to caller srli x7x712 sili x28,x12, 2 add / x5, x5, 28 sdx5 0 (x7 jalr x0 , 0(x1) x5 x5,x28 # START of the application START # Stack pointer Initialization 1dsp,TSTACK (xO) # Global pointer Initialization aupc x3, GLOBAL srli x3, x3, 12 # The rest of the code goes here public class FractionClient public static void main (String[l args) Fraction anew Fraction (3,8); Fraction bnew Fraction (1,2); a.add (b) System. out.print (a.getNumerator ) System.out.print('/") System.out.print (a.getDenominator ))

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

Organizing Your Speech Points

Answered: 1 week ago