Name: Date:
HW3.
-
(10 points) Consider the following 32-bit binary items.
0000 0000 1000 0100 0000 0100 0011 0011
0100 0000 0101 0100 1000 0100 0011 0011
a. Assuming the items above are instructions, what RISC-V assembly instructions do they represent? (Include all operands to the instruction in your answer.)
b. Assuming the items above are data (i.e. base 10 integers), what value do they represent?
c. How can you tell if the bits represent instructions or data? Explain your answer.
d. Could the bit patterns represent anything else besides instructions, integers, and memory addresses? If so, give some examples.
-
(6 points) Convert the following C code to RISC-V assembly instructions. Use the minimum number of instructions necessary. Assume that variables f, g and h are 32- bit integers stored in registers
x5
,x6
andx7
respectively and that the base address of arrays A and B are in registersx8
andx9
respectively. A and B are arrays of 4-byte integers (this is important). If you need to store temporary values, use one of the other registers.
a.f = 1; A[f] = 0;
b.
B[1] = A[f-5];
-
(4 points) Show the hexadecimal representation of the following RISC-V instructions. Show your work.
a.addi x7, x7, 4
b.
lw x9, 8(x5)