Write the following sequence of code into RISC-V assembler. Assume that x, y, and z are stored in registers x18, x19, and x20 respectively.
z = z + y - x - 4;
Write the following sequence of code into RISC-V assembler. Assume that x, y, and z are...
3- [8 points] Write the following sequence of code into RISC-V assembler: x=x-y-z+4; Assume that x, y, and z are stored in registers x18, x19, and x20 respectively.
IN RISC-V a) Consider the RISC-V code below. Indicate what is the value in register x20 after the code below is executed, and explain why; ori x18 x0 16 addi x20 x18 0 beq x20, x18, HERE add x20 x20, x20 b) Assume that the code above is part of a procedure called by main. What happens with the stack pointer during the procedure execution and why? Draw and explain. c) Add instructions to the above code to implement your...
4. Convert the below C code snippet to LEGV8 assembly code. Base address of x is stored in register X19. Assume variables a, b, andc are stored in registers X20, X21, and X22 respectively. Assume all values are 64-bits. Do not use divide and multiply instructions in your code. Comment your assembly code. (30 Points) x[e] a x[1]; q [e]x x[a/2]b; x[2]; + x[1] x[2] x[c] C >> 4: x[1] + 4. Convert the below C code snippet to LEGV8...
2.7 5<S$2.2, 2.3> Translate the following C code to RISC-V. Assume that the variables f, g, h, i, and j are assigned to registers x5, x6. x7. x28, and x29, y. Assume that the base address of the arrays A and B are in registers x10 and x11, respectively. Assume that the elements of the arrays A and B are 8-byte words: 2.7 5 Translate the following C code to RISC-V. Assume that the variables f, g, h, i, and...
1. Convert the following C statement to MIPS code. Assume x, y and z are assigned to registers $s0, $s1 and $s2 respectively and the starting address of array A is $s6. x = y + z + A[3] 2. 2.Convert the following C statement to MIPS code. Assume the base address of array A is $s3 and h is assigned to register $s2 . A[7] = h + A[7]
Problem 4 (30 points) a) Consider the RISC-V code below. Indicate what is the value in register x20 after the code below is executed, and explain why; х18 х0 16 ori addi x20 х18 0 beg x20, х18, НERE x20 х20, х20 add HERE Problem 4 (30 points) a) Consider the RISC-V code below. Indicate what is the value in register x20 after the code below is executed, and explain why; х18 х0 16 ori addi x20 х18 0 beg...
1- What is true about the following code sequence: addi x18, x0, 1 addi x19, x0, 2 addi x20, x0, 2 addi x21, x0, 4 addi x22, x0, 5 Must stall on the addi results Can avoid stalls using only forwarding Can execute without stalling or forwarding None of the above 2- What is true about the following code sequence: ld x9, 64(x22) add x9, x21, x9 Must stall on the ld result Can avoid stalls using only forwarding Can...
Write an equivalent MIPS code for the following C code. Assume that the base address of an array A is stored in register 450. Variables x, i, j and h are stored in registers $t0,$t1, $t2 and $t3 respectively. do{ x = x + A[i]; i = i + j; } (while i != h); Make sure your MIPS code has sufficient comments.
Problem 1 (15 points) Translate the C code below into RISC-V, knowing that the values of i and j are in registers x28 and x29, respectively. The base address of array B is in register x30, and the base address of array C is in register x31.
Registers in RISC-V are 64-bit. For the sake of simplicity, consider the following instructions operating on 32-bit registers. Assume that registers x5 and x6 hold the values 0xEEEEEEEE and 0x00000000, respectively. • (2 points) – What is the value in x6 for the following slli x6, x5, 6 • (2 points) – Using the result from the part above, what is the value in x6 for the following instruction. srli x6, x6, 6