You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to run a simple C program on a PULPino RISC-V platform, but I am encountering issues with floating-point printf output. The program performs some basic floating-point operations (addition and subtraction) and then attempts to print the results using printf. However, the output is incorrect, with the floating-point values not being printed as expected.
Here is the C code:
c
#include <stdio.h>
int main() {
float a = 4.2;
float b = 3.1;
float c;
float d;
c = a + b;
d = a - b;
printf("Toplam=%f", c);
printf("Fark=%f", d);
return 0;
GCC_MARCH="IMFDXpulpv2 -mhard-float"
GNU version 5.2.0
When I examine the generated assembly code (before it's converted to the s19 format), I notice that the floating-point values are being loaded into integer registers (e.g., a4) instead of floating-point registers (e.g., fa0) before the printf calls. This seems to be causing the incorrect output.
Furthermore, when I try to compile the code with optimization disabled (-O0), I get the following error:
error: insn does not satisfy its constraints:
}
(insn 54 30 31 2 (set (reg:DF 14 a4)
(reg:DF 47 fa5 [orig:80 D.2652 ] [80])) /home/har/Documents/pulpino/sw/apps/helloworld/helloworld.c:21 342 {*movdf_hardfloat_rv32}
(nil))
This error suggests that the compiler is trying to generate a movdf (double-precision move) instruction that doesn't satisfy the constraints of the target machine.
However, none of these attempts have resolved the issue.
I suspect that there might be a problem with how the compiler is handling floating-point values and register allocation for the PULPino platform, possibly related to the f extension for single-precision floating-point support.
I would appreciate any insights or suggestions on how to resolve this issue. Please let me know if you need any additional information.
Thank you for your help!
The text was updated successfully, but these errors were encountered:
I am attempting to run a simple C program on a PULPino RISC-V platform, but I am encountering issues with floating-point printf output. The program performs some basic floating-point operations (addition and subtraction) and then attempts to print the results using printf. However, the output is incorrect, with the floating-point values not being printed as expected.
Here is the C code:
c
#include <stdio.h>
int main() {
float a = 4.2;
float b = 3.1;
float c;
float d;
}
I am using the following toolchain and settings:
GCC_MARCH="IMFDXpulpv2 -mhard-float"
GNU version 5.2.0
When I examine the generated assembly code (before it's converted to the s19 format), I notice that the floating-point values are being loaded into integer registers (e.g., a4) instead of floating-point registers (e.g., fa0) before the printf calls. This seems to be causing the incorrect output.
Furthermore, when I try to compile the code with optimization disabled (-O0), I get the following error:
This error suggests that the compiler is trying to generate a movdf (double-precision move) instruction that doesn't satisfy the constraints of the target machine.
However, none of these attempts have resolved the issue.
I suspect that there might be a problem with how the compiler is handling floating-point values and register allocation for the PULPino platform, possibly related to the f extension for single-precision floating-point support.
I would appreciate any insights or suggestions on how to resolve this issue. Please let me know if you need any additional information.
Thank you for your help!
The text was updated successfully, but these errors were encountered: