Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Initial support for OpenWatcom soft floating point #2246

Merged
merged 2 commits into from
Feb 27, 2025
Merged

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Feb 27, 2025

Adds initial support for software (emulated) floating point to ELKS programs compiled with OpenWatcom C.

Discussed in #2239 (comment).

By default, inline 8087 support is turned off, and ewcc uses the -msoft-float option (-Wc,-fpc) to produce calls to software floating point routines contained in the C library for float and double precision floating point.

In order to turn on %f, %e and %g printf output, the following must be included in the application source in a function somewhere, or the dtostr() double-to-string formatting routines will not be linked in, and nothing will be output. Due to technical issues with weak symbols, only medium and large models are currently supported:

#include <sys/linksym.h>
#include <stdio.h>
int main(int ac, char **av)
{
    __STDIO_PRINT_FLOATS;  /* link in libc floating point printf support */
    ...
}

The above code is not necessary if floating point numbers do not need to be displayed using printf.

There is currently no math library for OWC. OWC documentation states that software emulated floating point is not IEEE 754 compliant; it is unknown exactly what that means.

This is a feature preview, it is not recommended to start using floating point in your own programs without special testing. This PR has been tested with ELKS basic, which seems to work, although still no math library. Producing a math library may not be easily possible, depending on learning more about non-IEEE support for emulated floating point, and/or porting the OWC math library vs the ELKS math library.

Programmers should remove any inline hardware 8087 code generation options (e.g. -Wc,-fpi or -Wc,-fpi87) and use ewcc or add -msoft-float to their OWCC command line.

Support for FP overflow and underflow is non-existent, and may produce entirely incorrect results and/or abort program execution. Fix coming.

The OWC floating point emulation library has some 8087 and 80386 code in it that had to be included - it is not known whether or how well OWC programs will run on older 8086 hardware - this still needs testing. In the future, a basic.os2 built with OWC will be supplied for testing on 8086 hardware.

@ghaerr ghaerr merged commit 8df0177 into master Feb 27, 2025
2 checks passed
@ghaerr ghaerr deleted the owcfloat branch February 27, 2025 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant