senecamarie5350 senecamarie5350
  • 08-04-2020
  • Computers and Technology
contestada

Translate function f into RISC-V assembly language. Assume the function declaration for g is int g(int a, int b). e code for function f is as follows: int f(int a, int b, int c, int d){ return g(g(a,b), c d); }

Respuesta :

naqiraza944 naqiraza944
  • 12-04-2020

Answer:

int f(int a, int b, int c) {

return func(func(a, b), c);

}

f: addiu $sp, $sp, -8 # allocate frame = 8 bytes

sw $ra, 0($sp) # save return address

sw $a2, 4($sp) # save c

jal func # call func(a,b)

move $a0, $v0 # $a0 = result of func(a,b)

lw $a1, 4($sp) # $a1 = c

jal func # call func(func(a,b),c)

lw $ra, 0($sp) # restore return address

addiu $sp, $sp, 8 # free stack frame

jr $ra # return to caller

Answer Link

Otras preguntas

What does it mean to say that momentum is conserved?
Substitution method X = 4 2x - 3y = -19
What is "la pista de pogo" mean in Spanish
What is 3 square root of 24- 4 square root of 54
why was Richard Arkwright important in the industrial revolution?
One light beam has wavelength, λ1, and frequency, f1. Another light beam has wavelength, λ2, and frequency, f2. Write a proportion that shows how the ratio of t
Why was the Dudley castle built?
Substitution method 1) 3x + y = 7 4x + 2y = 16 2) 2x + 2y = 4 X - 2y = 0
How did the people of the French Revolution overthrow the government?
A child throws a ball up in the air to a height of 3.5 m and catches it at the same point from which he threw it. The ball is in the air for a total of 1.7 s. W