Question

Show the single RISC-V instruction or minimal sequence of instructions for this C statement: b =...

Show the single RISC-V instruction or minimal sequence of instructions for this C statement: b = 25 | a. Assume that a corresponds to register x0 and b corresponds to register x1. Write each instruction in a separate box.

Homework Answers

Answer #1

a = b - P[Q[4]];.

For the C statement above, below is the MIPS code

lw $x0, 16($x7) //a = Q[4]

sll $x0, $x0, 2 //a = a*4 = Q[4]*4
add $x0, $x0, $x6 //a = &P[a] = &P[Q[4]]
lw $x0, 0($x0) //a = P[a] = P[Q[4]]
sub $x0, $x1, $x0 //a = b-a = b-P[Q[4]]
variables a, b, c, d, and e are assigned to registers $x0, $x1, $x2, $x3, and $x4, respectively. Assume that the base address of the arrays P and Q are in registers $x6 and $x7, respectively. a = b - P[Q[4]];
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Question 1. Answer the following questions on MIPS Instruction Set. a) Show the minimal sequence of...
Question 1. Answer the following questions on MIPS Instruction Set. a) Show the minimal sequence of MIPS instruction for the following pseudocode segment: A[3] = A[10] + B; Assume that B corresponds to register $t3 and the array A has a base address of 1000C41016 which is required to be loaded to register $t0 in your code. Provide comments for each line of your MIPS instruction. b) Assume that Loop starts at memory location 0xC010. Provide a) instruction format of...
I. What value will be in register r2 after execution of the following instructions? Show your...
I. What value will be in register r2 after execution of the following instructions? Show your work with the register values after executing each instruction. MOV r2, #0x0 LDR r1, =0xCF MOVS r1, r1, LSR #1 ADC r2, r2, #0 MOVS r1, r1, LSR #1 ADC r2, r2, #0 II. Assume a 32 bit register holds a data of four bytes as B3B2B1B0. Write a sequence of ARM instruction that takes this data as input and swaps the bytes 0...
(Pipelining) Given 3 different instruction types, A, B and C. Each type-A, B, and C instruction...
(Pipelining) Given 3 different instruction types, A, B and C. Each type-A, B, and C instruction takes 40ns, 25ns and 50ns to complete, respectively. An assembly program is written with 30 type-A, 40 type-B and 20 type-C instructions. (a). Assume a single-issue not pipelined processor, how much time (in nano-seconds) is required to complete the execution of this program? (10pts) (b). Now let us pipeline these instructions based on a cycle time of 10ns. To pipeline these instructions equally and...
Consider a program having following sequence of instructions, where the syntax consists of an opcode followed...
Consider a program having following sequence of instructions, where the syntax consists of an opcode followed by the destination register followed by one or two source registers: Instruction no Instructions 1 ADD R3, R1, R2 2 LOAD R6, [R3] 3 AND R7, R5, 3 4 ADD R1, R6, R0 5 SUB R2, R1, R6 6 AND R3, R7, 15 7 SUB R5, R3, R4 8 ADD R0, R1, R10 9 LOAD R6, [R5] 10 SRL R7, R0, 8 Assume the...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in BL. Bits 6-7 in BL should be cleared, and AL should be unchanged             Mov al, bl       And 00111111, bl       Write a sequence of two instructions that copies the integer in bits 4-7 from AL register into bits 0-3 of the BL register. Upper 4 bits of AL and BL will be cleared             Shr al, 4       Mov bl,...
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables...
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, and I are assigned to registers $s0 - $s3, respectively. Assume that the base address of arrays X, Y, and Z are in registers $s4 - $s6, respectively. Be conservative and use a single temp register as possible. It is a C arithmetic command with two source operands and a destination. Each part is 3 points. Add $t0, $s0, $s1 addi...
Referring to Friday’s class presentation on “condition flags” (Z=zero, N=negative, C=carry, V=overflow), assume the operation A-B...
Referring to Friday’s class presentation on “condition flags” (Z=zero, N=negative, C=carry, V=overflow), assume the operation A-B is performed using two’s complement arithmetic. For each of the following six relationships, write a logic expression in terms of Z, N, C, and/or V that evaluates to 1 if that relationship is true, based on the result of A-B. A = B A != B (not equal) A > B A ≥ B A < B A ≤ B
AP Computer Science A FRQ SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE...
AP Computer Science A FRQ SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined...
Instructions a) Calculate the value or the ratio of items in the boxes b) Show your...
Instructions a) Calculate the value or the ratio of items in the boxes b) Show your work by specifiying the formula you used for each of these calculations. c) For $ values, no need to leave any decimals, e.g Gross Profit = $34,000. d) Leave ratios and percentages in 2 decimal place, e.g. TIE = 2.81; ROA = 4.83%; etc. Suggestion: calculate the yellow subtotals before going on to answer individual questions (e.g. the current assets, etc.). These are intermediate...
What is a Capital Asset?, Holding Period, Calculation of Gain or Loss, Net Capital Losses (LO...
What is a Capital Asset?, Holding Period, Calculation of Gain or Loss, Net Capital Losses (LO 8.1, 8.2, 8.3, 8.5) Charu Khanna received a Form 1099-B showing the following stock transactions and basis during 2016: Stock Date Purchased Date Sold Sales Price Cost Basis 4,000 shares Green Co. 06/04/05 08/05/16 $12,000 $3,000 500 shares Gold Co. 02/12/16 09/05/16 54,000 62,000 5,000 shares Blue Co. 02/04/06 10/08/16 18,000 22,000 100 shares Orange Co. 11/15/15 07/12/16 19,000 18,000 None of the stock...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT