Skip to content

Implement __aeabi_f2d and __aeabi_d2f #356

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

Merged
merged 1 commit into from
Mar 23, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 41 additions & 10 deletions stm/math.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
#include <stdint.h>
#include <math.h>

// these 2 functions seem to actually work... no idea why
// replacing with libgcc does not work (probably due to wrong calling conventions)
double __aeabi_f2d(float x) {
// TODO
return 0.0;
typedef float float_t;
typedef union {
float f;
struct {
uint64_t m : 23;
uint64_t e : 8;
uint64_t s : 1;
};
} float_s_t;

typedef union {
double d;
struct {
uint64_t m : 52;
uint64_t e : 11;
uint64_t s : 1;
};
} double_s_t;

double __attribute__((pcs("aapcs"))) __aeabi_f2d(float x) {
float_s_t fx={0};
double_s_t dx={0};

fx.f = x;
dx.s = (fx.s);
dx.e = (fx.e-127+1023) & 0x7FF;
dx.m = fx.m;
dx.m <<=(52-23); // left justify
return dx.d;
}

float __aeabi_d2f(double x) {
// TODO
return 0.0;
float __attribute__((pcs("aapcs"))) __aeabi_d2f(double x) {
float_s_t fx={0};
double_s_t dx={0};

dx.d = x;
fx.s = (dx.s);
fx.e = (dx.e-1023+127) & 0xFF;
fx.m = (dx.m>>(52-23)); // right justify
return fx.f;
}
double __aeabi_dmul(double x , double y) {
return 0.0;

}
/*
double sqrt(double x) {
// TODO
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy