contribute by <david070889>
Choosing Problem B from Quiz 1.
According to the assignment requirements, the first task i need to do is to translate C
to assembly
.
C
Assembly
The original C source code probably using exponential and logarithm to compute the root of a number.
I couldn't figure out a way to implement these two function using RISC-V RV32I.
Instead, I decide to use Newton-Raphson method
to implement the n-th Root of x.
Here is the function of calculating the n-th Root of x.
n is the degree of the root, x is the number to be rooted, y is the guessing result according to the Newton's method and k is the iteration time.
For this assignment, x is a positive number, and n is a positive integer.
nth_root.c
This function is constructed using built-in C functions, so I need to translate some of them into floating-point bitwise operation.
nth_root_translate.c
In this function, we can see that basically every function were translate into floating-point bitwise operation.
At the end, I translated the entire nth_root.c
into nth_root_FP32.s
.
Combine both nth_root_FP32
and FP32_to_BF16
.
FP32 | BF16 |
---|---|