logo

UTK Notes


RISC-V Floating Point Practice

Question 1

What instruction moves a value from an integer register to a floating-point register and converts it?

fcvt.w.s

Question 2

Given the following C++ code:

1
2
3
4
5
int main() {
   float *ptr = (float *)70;
   
   float value = ptr[13];
}

What memory address is dereferenced with the code ptr[13] if the pointer ptr points to the memory location 70?

122

Question 3

Given the assembly code below:

??? fa0, 0(sp)

Write the instruction ??? to store the double-precision value in fa0 to the memory address *(sp + 0):

fsd

Question 4

Given the following code:

.text
main:
   flw  fa0, 11(sp)

What memory address  would be loaded from given the instruction above if the stack pointer is pointing to the value 461?

472

Question 5

What instruction multiplies two double-precision values?

fmul.d

Question 6

Like x0, writes to f0 are discarded and the value of f0 is always 0.0.

False

Question 7

Given the following prototype:

1
double MyFunc(float a, double b, int c, int *d, float *e);

write the registers that get the parameters a through e and the return register.

fa0 MyFunc(fa0, fa1, a0, a1, a2)

Question 8

Given the following code:

.text
main:
   ???  t0, fa0, fa1

What instruction will put 1 into t0 if the single-precision value in fa0 is GREATER THAN the single-precision value in fa1?

fgt.s

Question 9

The instruction “call home” is an alias for which of the following real instructions?

jal ra, home

Question 10

Given the following C++ code:

1
2
3
4
5
int main() {
   double *ptr = (double *)77;
   
   double value = ptr[14];
}

What memory address is dereferenced with the code ptr[14] if the pointer ptr points to the memory location 77?

189

Question 11

The stack pointer must contain a value that is aligned to what value?

16

Question 12

The instruction fmv.s.x moves a value from an integer register into a single-precision floating point register and does not convert it.

Question 13

Given the following code:

.text
main:
   fld  fa0, 3(sp)

What memory address  would be loaded from given the instruction above if the stack pointer is pointing to the value 251?

254

Question 14

Single-precision floating point instructions end with which of the following suffixes?

Example: fgt.?

.s

Question 15

Given the following assembly code:

.data
mystuff: .word 100

.text
main:
   ??? t0, mystuff

What would you write in ??? to put the memory address of the label mystuff into the register t0?

la