subject

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;

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:00
You will be given two character arrays of the same size, one will contain a number of ships. ships will move around the character array based on which way they are facing and the route they are on. routes are given in the other array. the route consists of '-' and '|' for straight paths, '\' and '/' for curves, and '+' for intersections. there are ships on these routes. ships always face a direction, '^' for up, '> ' for right, 'v' for down, and '< ' for left. any time the ships hit a '\' or a '/' it will turn as you would expect a ship to turn (e.g. a '^' that moves into a '/' will turn right). at an intersection, ships will always continue straight through. all ships move at the same speed, ships take turns moving and all ships move during one 'tick'. the one in the most top left goes first, followed by those to its right, then the ones in the next row. it iterates along the rows and then down the columns. each ship moves one space on its turn moving along the route. your function needs to return the position of the first collision between two ships and the number of ticks before the crash occurred.
Answers: 2
question
Computers and Technology, 22.06.2019 10:00
Jackson is teaching the decimal number system. he wants his students to know how to expand numbers by powers of 10. which is the correct order in which digits are assigned values in the decimal number system?
Answers: 1
question
Computers and Technology, 22.06.2019 22:10
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
Write a program in plp assembly that counts up by one starting from zero (or one) inside a loop and writes this value to the leds every time the value is increased. the memory address of the leds is 0xf0200000. the table below shows the meaning and an example usage of the instructions covered in the video, plp instructions for project 1. instruction example usage meaning load immediate li $t0, 8 register $t0 is set to the value, 8. store word sw $t2, 0($t1) the value in register $t1 is used as the memory address. the value in register $t2 is copied into this memory address. add addiu $t4, $t3, 29 register $t4 is assigned the sum of 29 and the value in register $t3. jump j your_label_name the program jumps to the line following the label, "your_label_name: ". label your label name: defines a label called "your_label_name: " that can be jumped to
Answers: 2
You know the right answer?
In each of the following questions, you'll be given either C or RISC-V code, and asked to examine a...
Questions
question
Mathematics, 30.01.2020 14:51
Questions on the website: 13722362