News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Berkeley SoftFloat

Started by TimoVJL, August 09, 2017, 07:39:18 PM

Previous topic - Next topic

TimoVJL

Berkeley SoftFloat support 80-bit and 128-bit floats too.
I try to get it work with PellesC.

example#include <stdio.h>
#define SOFTFLOAT_FAST_INT64
#include <SoftFloat.h>
#include <primitiveTypes.h>
#if defined(_WIN64) || __POCC_TARGET__ >= 3
#pragma comment(lib, "SoftFloat3x64.lib")
#else
#pragma comment(lib, "SoftFloat3.lib")
#endif

int __cdecl main(int argc, char **argv)
{
char buf[128];
unsigned char *p;
extFloat80_t f80 = i32_to_extF80( 1 );
extFloat80_t f80s = extF80_add(f80, f80);
p = (unsigned char *)&f80;
for (int i=0; i<10; i++) printf("%02X ", (unsigned char)*p++);
puts("");
p = (unsigned char *)&f80s;
for (int i=0; i<10; i++) printf("%02X ", (unsigned char)*p++);
puts("");
float128_t f128 = ui64_to_f128( 1 );
p = (unsigned char *)&f128;
for (int i=0; i<16; i++) printf("%02X ", (unsigned char)*p++);
puts("");
return 0;
}
EDIT: missing platform.h and msvcrt_void.c added.
EDIT: project with source in zip TestSoftFloat80_WS_src.zip

To test ready-made libraries, use SoftFloat3_WS_test.zip and SoftFloat3lib.zip as example.
May the source be with you

jj2007

The IDE says
Don't know how to build "C:\Masm32\PellesC\Projects\Timo\SoftFloat\source\extF80_add.c".
:(
Anything else missing?

TimoVJL

#2
It was without source.

Downloaded from here

EDIT: project with source in zip TestSoftFloat80_WS_src.zip
May the source be with you

jj2007

Any idea why the IDE tells me "Bad version on TestSoftFloat80X64.ppj"?

TimoVJL

#4
It happens, if someone opened workspace in poide.exe version 8 (32-bit)
May the source be with you

jack


jack

I built the softfloat lib with ioldouble included, but can't compile this simple example

#include <stdio.h>
#include "SoftFloat.h"
#include "primitiveTypes.h"

extern void e64toasc(extFloat80_t *x, char *string, int ndigs);
extern void asctoe64( char *s, extFloat80_t *x );

int __cdecl main(int argc, char **argv)
{
char buf[128]="3.1415926535897932384626433832795";
extFloat80_t f80;
asctoe64( buf, &f80 );
e64toasc( &f80, buf, 10 );
printf("%s\n",buf);
return 0;
}

POLINK: error: Unresolved external symbol 'alloca'

TimoVJL

add#include <stdlib.h>and use compiler option -Go Define compatibility names.
May the source be with you

jack

I already tried that but no luck, gcc has no problem.

jack

your advise is good, but it also had to be applied to building the soft float lib, now it works without complaints.

#include <stdio.h>
#include <stdlib.h>

#include "SoftFloat.h"
#include "primitiveTypes.h"

extern void e64toasc(extFloat80_t *x, char *string, int ndigs);
extern void asctoe64( char *s, extFloat80_t *x );
extern void e113toasc(float128_t *x, char *string, int ndigs);
extern void asctoe113( char *s, float128_t *x );

int __cdecl main(int argc, char **argv)
{
char buf[128]="3.1415926535897932384626433832795028842";
float128_t f128, f128b;
asctoe113( buf, &f128 );
f128M_add(&f128, &f128, &f128b);
e113toasc( &f128b, buf, 33 );
printf("%s\n",buf);
return 0;
}

Quote
6.283185307179586476925286766559006E0

TimoVJL

Only the project need that with ioldoubl, not SoftFloat3.lib.

I haven't check if ioldoubl.c needs splitting for smaller code size, as PellesC don't support COMDAT.

Nice to see that someone is testing it ;)
May the source be with you

jack

#11
a bit off topic, I hope won't mind.
I did some timing on softfloat3c and QD https://github.com/scibuilder/QD and QD is from 1.7 to 3.5 times faster, up to 5.7 faster in 32-bit vs softfloat x86
but I manually edited the makefile for the 32-bit build to use sse2 otherwise if using the fpu one has to use fpu_fix_start and fpu_fix_end between calculations, slowing things down considerably.

TimoVJL

#12
Hardly, people like also to know other or better options.

QD is programmed in C++, so not so usable for C without making a dll.
Average gcc programmer even notice that in their tests, what have to link with static libs.
May the source be with you