Computers and Technology

In each of the following questions, you'll be given either C or RISC-V code, and asked to examine a translation into RISC-V or C, respectively.

The translation may have a bug or logic error. Your task is to identify the line number containing the error, or enter "none" if no problem exists.

(a) Given this C code:

if (x < 3) {
goto label;
}
Identify the buggy line in the following RISC-V translation. Select "None", if there is no error.

/* x = s0 */
1. addi t0 x0 3
2. slt t1 s0 t0
3. beq t1 x0 label
(b) Given this C code:

int x[2] = {1, 2}
int y = x[0] + x[1] + 2;
identify the buggy line in the following RISC-V translation or enter "none", if there is none:

/* x = s0, y = s1 */
1. lw t0 0(s0)
2. lw t1 1(s0)
3. add s1,t0,t1
4. addi s1,s1,2
(c) Given this RISC-V code:

add s0 s0 s2
sub s1 s2 s1
j end
identify the buggy line in the following C translation or enter "none", if there is none. (Hint: register order matters):

/* x = s0, y = s1, z = s2 */
1. x += z
2. y -= z
3. goto end
(d) Given this RISC-V code:

slli s0 s0 4
xori s0 s0 3
sw s0 8(s1)
identify the buggy line in the following C translation or enter "none", if there is none:

1. int x; // x = s0
2. int y[3]; // y = s1
3. x *= math. pow(2, 4);
4. x ^= 3
5. y[4] = x;

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:20, mayaparness
Write a program that prompts the user to input a string. the program then uses the function substr to remove all the vowels from the string. for example, if str = "there", then after removing all the vowels, str = "thr". after removing all the vowels, output the string. your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.
Answers: 2
image
Computers and Technology, 23.06.2019 05:20, jaylenmiller437
Which operating system is a version of linux?
Answers: 1
image
Computers and Technology, 23.06.2019 15:00, Siris420
Plz ( which is an example of a good url?
Answers: 1
image
Computers and Technology, 25.06.2019 08:10, aneisha0117
Which of the following statements is false? a. package access is rarely used. b. use the access modifier package to give a method or variable package access. c. classes in the same source file are part of the same package. d. if a program uses multiple classes from the same package, these classes can access each other's package access members directly through references to objects of the appropriate classes, or in the case of static members, through the class name.
Answers: 1
Do you know the correct answer?
In each of the following questions, you'll be given either C or RISC-V code, and asked to examine a...

Questions in other subjects:

Konu
Arts, 26.10.2021 02:00