Question: CODE FOR DISCRETE_FN.S .data neg3: .asciiz f(-3) should be 6, and it is: neg2: .asciiz f(-2) should be 61, and it is: neg1:

 CODE FOR "DISCRETE_FN.S" .data neg3: .asciiz "f(-3) should be 6, and

CODE FOR "DISCRETE_FN.S" .data neg3: .asciiz "f(-3) should be 6, and it is: " neg2: .asciiz "f(-2) should be 61, and it is: " neg1: .asciiz "f(-1) should be 17, and it is: " zero: .asciiz "f(0) should be -38, and it is: " pos1: .asciiz "f(1) should be 19, and it is: " pos2: .asciiz "f(2) should be 42, and it is: " pos3: .asciiz "f(3) should be 5, and it is: " output: .word 6, 61, 17, -38, 19, 42, 5 .text main: la a0, neg3 jal print_str li a0, -3 jal f # evaluate f(-3); should be 6 jal print_int jal print_newline la a0, neg2 jal print_str li a0, -2 jal f # evaluate f(-2); should be 61 jal print_int jal print_newline la a0, neg1 jal print_str li a0, -1 jal f # evaluate f(-1); should be 17 jal print_int jal print_newline la a0, zero jal print_str li a0, 0 jal f # evaluate f(0); should be -38 jal print_int jal print_newline la a0, pos1 jal print_str li a0, 1 jal f # evaluate f(1); should be 19 jal print_int jal print_newline la a0, pos2 jal print_str li a0, 2 jal f # evaluate f(2); should be 42 jal print_int jal print_newline la a0, pos3 jal print_str li a0, 3 jal f # evaluate C(4,0); should be 5 jal print_int jal print_newline li a0, 10 ecall # calculate f(a0) f: la t0, output # Hmm... why might this be a good idea? # YOUR CODE GOES HERE! jr ra # Always remember to jr ra after your function! print_int: mv a1, a0 li a0, 1 ecall jr ra print_str: mv a1, a0 li a0, 4 ecall jr ra print_newline: li a1, ' ' li a0, 11 ecall jr ra

Exercise 2: Write a function without branches Consider the discrete-valued function f defined on integers in the set -3, -2,-1, 0, 1, 2, 3). Here's the function definition f (-3) -6 f (-2)-61 f(-1) = 17 f(0) =-38 f (1) - 19 f (2)42 Your task is to implement it in RISC-V, with the condition that your code may NOT use any branch instructions! You can use the file "discrete fn.s" for this exercise. Notice that there is an array of integers in the .data section of "discrete_fn.s" How can you use this to your advantage and complete this task? Exercise 2: Write a function without branches Consider the discrete-valued function f defined on integers in the set -3, -2,-1, 0, 1, 2, 3). Here's the function definition f (-3) -6 f (-2)-61 f(-1) = 17 f(0) =-38 f (1) - 19 f (2)42 Your task is to implement it in RISC-V, with the condition that your code may NOT use any branch instructions! You can use the file "discrete fn.s" for this exercise. Notice that there is an array of integers in the .data section of "discrete_fn.s" How can you use this to your advantage and complete this task

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!