URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
297 |
jeremybenn |
struct sw {
|
2 |
|
|
const void *x;
|
3 |
|
|
int r;
|
4 |
|
|
};
|
5 |
|
|
struct sq {
|
6 |
|
|
struct sw *q_w;
|
7 |
|
|
int t;
|
8 |
|
|
int z;
|
9 |
|
|
};
|
10 |
|
|
|
11 |
|
|
int
|
12 |
|
|
f (int ch, char *fp, char *ap)
|
13 |
|
|
{
|
14 |
|
|
register int n;
|
15 |
|
|
register char *cp;
|
16 |
|
|
register struct sw *p;
|
17 |
|
|
register int f;
|
18 |
|
|
int prec;
|
19 |
|
|
double _double;
|
20 |
|
|
int expt;
|
21 |
|
|
int ndig;
|
22 |
|
|
char expstr[7];
|
23 |
|
|
unsigned long long _uquad;
|
24 |
|
|
struct sq q;
|
25 |
|
|
struct sw w[8];
|
26 |
|
|
static char zeroes[16];
|
27 |
|
|
|
28 |
|
|
for (;;) {
|
29 |
|
|
switch (ch) {
|
30 |
|
|
case 'd':
|
31 |
|
|
_double = (double) (ap += 8, *((double *) (ap - 8)));
|
32 |
|
|
break;
|
33 |
|
|
case 'o':
|
34 |
|
|
goto nosign;
|
35 |
|
|
case 'u':
|
36 |
|
|
_uquad = (f & 0x020 ? (ap += 8, *((long long *) (ap - 8))) : f & 0x010 ? (ap += 4, *((long *) (ap - 4))) : f & 0x040 ? (long)(short)(ap += 4, *((int *) (ap - 4))) : (long)(ap += 4, *((int *) (ap - 4))));
|
37 |
|
|
goto nosign;
|
38 |
|
|
case 'x':
|
39 |
|
|
_uquad = (f & 0x020 ? (ap += 8, *((long long *) (ap - 8))) : f & 0x010 ? (ap += 4, *((long *) (ap - 4))) : f & 0x040 ? (long)(unsigned short)(ap += 4, *((int *) (ap - 4))) : (long)(ap += 4, *((int *) (ap - 4))));
|
40 |
|
|
nosign:
|
41 |
|
|
if (_uquad != 0 || prec != 0);
|
42 |
|
|
break;
|
43 |
|
|
default:;
|
44 |
|
|
}
|
45 |
|
|
if ((f & 0x100) == 0) {
|
46 |
|
|
} else {
|
47 |
|
|
if (ch >= 'f') {
|
48 |
|
|
if (_double == 0) {
|
49 |
|
|
if (expt < ndig || (f & 0x001) != 0) {
|
50 |
|
|
{ if ((n = (ndig - 1)) > 0) { while (n > 16) {{ p->x = (zeroes); p->r = 16; q.z += 16; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }} n -= 16; }{ p->x = (zeroes); p->r = n; q.z += n; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}}}
|
51 |
|
|
}
|
52 |
|
|
} else if (expt <= 0) {
|
53 |
|
|
{ p->x = ("0"); p->r = 1; q.z += 1; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}
|
54 |
|
|
{ p->x = 0; p->r = 1; q.z += 1; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}
|
55 |
|
|
{ if ((n = (-expt)) > 0) { while (n > 16) {{ p->x = (zeroes); p->r = 16; q.z += 16; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }} n -= 16; }{ p->x = (zeroes); p->r = n; q.z += n; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }} }}
|
56 |
|
|
{ p->x = cp; p->r = ndig; q.z += ndig; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}
|
57 |
|
|
} else {
|
58 |
|
|
{ p->x = cp; p->r = expt; q.z += expt; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}
|
59 |
|
|
cp += expt;
|
60 |
|
|
{ p->x = ("."); p->r = 1; q.z += 1; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}
|
61 |
|
|
{ p->x = cp; p->r = (ndig-expt); q.z += (ndig-expt); p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
error:;
|
68 |
|
|
}
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.