a) Value of x5 at the end of execution = 2
b) Value of x7 at the end of execution = 4
c) Total 5 number of instruction executed
Explanation:
At the start x6 = 5 is not equal to 0 hence branching will not take place.
In second line, x6 = x6 - 1 = 5-1 = 4
In third line x5 = x5+2 = 2
In fourth line x7 = 010 << 1 = 100 = (4)10
In fifth line branching will take place as x5>=0 ( 2>0) hence the code will branch to DONE.
Consider the following RISC-V loop: (i) LOOP: beq x6, XO, DONE (ii) addi x6, x6, -1...
Consider the following RISC-V assembly instructions: slt x6, x0, x5 bne x0, x6, ELSE j DONE ELSE: addi x6, x6, 2 DONE: a)For what value(s) of x5 is the addi instruction executed? b)Why?
Please do the following problems 1. translate into RISC-V Assembly variable rpt in x19 register. if(rpt>0){ rpt=rpt-1; goto loop } 2. Translate the following Risc-V code into C. variable 'i' in register x5, variable 'result' in x6 ,base address of integer 'memarray' in x10 addi x6,x0,0 addi x29,x0,100 LOOP: ld x7,0(x10) add x5,x5,x7 addi x10,x10,8 addi x6,x6,1 blt x6,x29, LOOP
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
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...
2. The table below holds MIPS assembly code fragments with different branch instructions LOOP addi $s2. $s2. 2 subi $t1. st1. 1 bne t1. 0. LOOP DONE: LOOP: it st2. $0. stl beq t2. 0. DONE addi $s2. Ss2. 2 LOOP DONE: For the loops written in MIPS assembly in the above table, assume that the register Şt1 is initialized to the value of 10. What is the value in register $s2 assuming that $s2 initially has a value of...
Consider the following MIPS code (don't worry about what it does): loop: beq $s0, $s1, done addi $t0, $t0, 7 addi St1, St2, 4 addi $s0, $s0, 1 j loop done: beq St1, $15, skip addi St0, Sto, 1 addi St1, St2, St0 skip addi $t5, $0, 10 beq St1, St5, done j end Compute the branch offset for each beq in number of words away from the branch (e.g., "branch offset is 2") Assume label loop is at location...
Consider the following MIPS assembly language instructions: addi $1, $2, 100 swr $1, 0($2): addi $rt, $rs, immediate # add immediate swr $rt, immedi ate ($rs) # store word write register These instructions are I-format instructions similar to the load word and store word instructions. The addi and swr instructions store a computed value to the destina- tion register $rt. The instructions do not require any physical hardware changes to the datapath. The effect of each instruction is given below....
Hey, I am confused about the following MIPS questions - could you also provide an explanation with your answer? Thank you! 1. What is the value in $t1 when the sw instruction is executed? (i.e. what value is stored in result) li $t1, 0 li $t2, 1 li $t3, 10 loop: bgt $t2, $t3, end_loop mul $t1, $t1, $t2 addi $t2, $t2, 1 j loop end_loop: sw $t1, result 2. (a) If the label job is at 0x00401000, what value...
1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume f, g, h correspond to $80, $s1, and $s2, respectively. f=g+(h-5) 2. (15 pts) For the following pseudo-MIPS assembly instructions, what is the corresponding C code? add f, g, h add f,i, f 3. (30 pts) Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following MIPS fields: a. op = 0, rs = 18, rt=9, rd...
please code using risc-v language and make it as simple as possible Problem 1: (20 marks) Part 1: (15 points) Compile the RISC-V assembly code for the following C code. Assume that n and k are passed in x3 and x4 respectively. Values n and k are initialized to 14 and 14. Assume that result returned in register fl and that double precision numbers are used. After you are done store the result in address: 12(x3). Are you allowed to?...