generate code for ACK assembler, including floats
This commit is contained in:
parent
235871bf4b
commit
5053f2a183
2 changed files with 36 additions and 10 deletions
|
@ -50,24 +50,50 @@ con_mult(sz) word sz; {
|
||||||
* The next function is difficult to do when not running on a PDP 11 or VAX
|
* The next function is difficult to do when not running on a PDP 11 or VAX
|
||||||
* The strategy followed is to assume the code generator is running on a PDP 11
|
* The strategy followed is to assume the code generator is running on a PDP 11
|
||||||
* unless the ACK_ASS define is on.
|
* unless the ACK_ASS define is on.
|
||||||
* In the last case floating point constants are simply not handled
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
con_float() {
|
con_float() {
|
||||||
#ifdef ACK_ASS
|
#ifdef ACK_ASS
|
||||||
static int been_here;
|
double f, f1;
|
||||||
|
double atof(), frexp(), modf();
|
||||||
|
int i, j;
|
||||||
|
int sign = 0;
|
||||||
|
int fraction ;
|
||||||
|
|
||||||
if (argval != 4 && argval != 8)
|
if (argval != 4 && argval != 8)
|
||||||
fatal("bad fcon size");
|
fatal("bad fcon size");
|
||||||
fprintf(codefile,".data4\t");
|
f = atof(str);
|
||||||
if (argval == 8)
|
f = frexp(f, &i);
|
||||||
fprintf(codefile,"F_DUM,");
|
if (f < 0) {
|
||||||
fprintf(codefile,"F_DUM\n");
|
f = -f;
|
||||||
if ( !been_here++)
|
sign = 1;
|
||||||
fprintf(stderr,"Warning : dummy float-constant(s)\n");
|
}
|
||||||
|
while (f < 0.5) {
|
||||||
|
f += f;
|
||||||
|
i --;
|
||||||
|
}
|
||||||
|
f = modf(2 * f, &f1); /* hidden bit */
|
||||||
|
i = (i + 128) & 0377;
|
||||||
|
fraction = (sign << 15) | (i << 7);
|
||||||
|
for (j = 6; j>= 0; j--) {
|
||||||
|
if (f >= 0.5) fraction |= (1 << j);
|
||||||
|
f = modf(2*f, &f1);
|
||||||
|
}
|
||||||
|
fprintf(codefile, ".data2 0%o", fraction);
|
||||||
|
for (i = argval / 2 - 1; i; i--) {
|
||||||
|
fraction = 0;
|
||||||
|
for (j = 15; j>= 0; j--) {
|
||||||
|
if (f >= 0.5) fraction |= (1 << j);
|
||||||
|
f = modf(2*f, &f1);
|
||||||
|
}
|
||||||
|
fprintf(codefile, ", 0%o", fraction);
|
||||||
|
}
|
||||||
|
putc('\n', codefile);
|
||||||
#else
|
#else
|
||||||
double f;
|
double f;
|
||||||
register short *p,i;
|
double atof();
|
||||||
|
int i;
|
||||||
|
short *p;
|
||||||
|
|
||||||
if (argval != 4 && argval != 8)
|
if (argval != 4 && argval != 8)
|
||||||
fatal("bad fcon size");
|
fatal("bad fcon size");
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* or for the standard UNIX V7 assembler.
|
* or for the standard UNIX V7 assembler.
|
||||||
* If on code is generated for the ACK assembler.
|
* If on code is generated for the ACK assembler.
|
||||||
*/
|
*/
|
||||||
/* #define ACK_ASS /* code for ACK assembler */
|
#define ACK_ASS /* code for ACK assembler */
|
||||||
|
|
||||||
#ifdef ACK_ASS
|
#ifdef ACK_ASS
|
||||||
#define COMMENTCHAR '!'
|
#define COMMENTCHAR '!'
|
||||||
|
|
Loading…
Reference in a new issue