Moved from /etc.

This commit is contained in:
dtrg 2007-02-25 12:42:04 +00:00
parent 880e3eade8
commit 877dc01422
2 changed files with 454 additions and 0 deletions

279
h/con_float Normal file
View file

@ -0,0 +1,279 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
/*
#define CODE_GENERATOR for code generator
#define CODE_EXPANDER for code expander
#define IEEEFLOAT for machines using IEEE floating point format
#define PDPFLOAT for machines using the PDP-11 floating point format
If none of these are defined, the format of the machine on which the
code generator runs is used.
Returns 1 if sz has an illegal value, 2 in case of overflow,
and 0 if all went well.
If neither IEEEFLOAT nor PDPFLOAT are defined, the return value is not
trustworthy.
Unfortunately, the IEEE standard does not define the byte-order.
depends on the #defines
FL_MSL_AT_LOW_ADDRESS 1 if most significant long is at low address
FL_MSW_AT_LOW_ADDRESS 1 if most significant word is at low address
FL_MSB_AT_LOW_ADDRESS 1 if most significant byte is at low address
*/
#ifdef IEEEFLOAT
#define USE_FLT
#endif
#ifdef PDPFLOAT
#define USE_FLT
#undef FL_MSL_AT_LOW_ADDRESS
#define FL_MSL_AT_LOW_ADDRESS 1
#undef FL_MSW_AT_LOW_ADDRESS
#define FL_MSW_AT_LOW_ADDRESS 1
#undef FL_MSB_AT_LOW_ADDRESS
#define FL_MSB_AT_LOW_ADDRESS 0
#endif
#define I0 ((FL_MSL_AT_LOW_ADDRESS ? 0 : 4) + (FL_MSW_AT_LOW_ADDRESS ? 0 : 2) \
+ (FL_MSB_AT_LOW_ADDRESS ? 0 : 1))
#define I1 ((FL_MSL_AT_LOW_ADDRESS ? 0 : 4) + (FL_MSW_AT_LOW_ADDRESS ? 0 : 2) \
+ (FL_MSB_AT_LOW_ADDRESS ? 1 : 0))
#define I2 ((FL_MSL_AT_LOW_ADDRESS ? 0 : 4) + (FL_MSW_AT_LOW_ADDRESS ? 2 : 0) \
+ (FL_MSB_AT_LOW_ADDRESS ? 0 : 1))
#define I3 ((FL_MSL_AT_LOW_ADDRESS ? 0 : 4) + (FL_MSW_AT_LOW_ADDRESS ? 2 : 0) \
+ (FL_MSB_AT_LOW_ADDRESS ? 1 : 0))
#define I4 ((FL_MSL_AT_LOW_ADDRESS ? 4 : 0) + (FL_MSW_AT_LOW_ADDRESS ? 0 : 2) \
+ (FL_MSB_AT_LOW_ADDRESS ? 0 : 1))
#define I5 ((FL_MSL_AT_LOW_ADDRESS ? 4 : 0) + (FL_MSW_AT_LOW_ADDRESS ? 0 : 2) \
+ (FL_MSB_AT_LOW_ADDRESS ? 1 : 0))
#define I6 ((FL_MSL_AT_LOW_ADDRESS ? 4 : 0) + (FL_MSW_AT_LOW_ADDRESS ? 2 : 0) \
+ (FL_MSB_AT_LOW_ADDRESS ? 0 : 1))
#define I7 ((FL_MSL_AT_LOW_ADDRESS ? 4 : 0) + (FL_MSW_AT_LOW_ADDRESS ? 2 : 0) \
+ (FL_MSB_AT_LOW_ADDRESS ? 1 : 0))
#ifndef USE_FLT
static int
float_cst(str, sz, buf)
char *str, *buf;
int sz;
{
int i;
char *p;
float fl;
double f;
double atof();
if (sz!= 4 && sz!= 8) {
return 1;
}
f = atof(str);
if (sz == 4) {
fl = f;
p = (char *) &fl;
}
else {
p = (char *) &f;
}
for (i = sz; i; i--) {
*buf++ = *p++;
}
return 0;
}
#else /* USE_FLT */
#include <ctype.h>
#include <flt_arith.h>
int
float_cst(str, sz, buf)
char *str, *buf;
int sz;
{
int overflow = 0;
flt_arith e;
if (sz!= 4 && sz!= 8) {
return 1;
}
flt_str2flt(str, &e);
#ifdef IEEEFLOAT
if (sz == 4) {
#endif
#ifdef PDPFLOAT
e.flt_exp += 129;
#else
e.flt_exp += 127;
#endif
if (e.flt_mantissa.flt_h_32 == 0) e.flt_exp = 0;
#ifdef IEEEFLOAT
if (e.flt_mantissa.flt_h_32 & 0x80) {
/* rounding */
if ((e.flt_mantissa.flt_h_32 & 0xffffff00) == 0xffffff00) {
e.flt_exp++;
e.flt_mantissa.flt_h_32 = 0x80000000;
}
else {
e.flt_mantissa.flt_h_32 += 0x80;
}
}
if (e.flt_exp >= 255) {
overflow = 1;
e.flt_exp = 255;
e.flt_mantissa.flt_h_32 = e.flt_mantissa.flt_l_32 = 0;
}
if (e.flt_exp <= 0) {
flt_b64_sft(&(e.flt_mantissa), 1);
if (e.flt_exp < 0) {
flt_b64_sft(&(e.flt_mantissa), -e.flt_exp);
e.flt_exp = 0;
}
}
#endif
#ifndef IEEEFLOAT
if (sz == 4 && (e.flt_mantissa.flt_h_32 & 0x80)) {
/* rounding */
if ((e.flt_mantissa.flt_h_32 & 0xffffff00) == 0xffffff00) {
e.flt_exp++;
e.flt_mantissa.flt_h_32 = 0x80000000;
}
else {
e.flt_mantissa.flt_h_32 += 0x80;
}
}
if (sz == 8 && (e.flt_mantissa.flt_l_32 & 0x80)) {
/* rounding */
if ((e.flt_mantissa.flt_l_32 & 0xffffff00) == 0xffffff00) {
e.flt_mantissa.flt_l_32 = 0;
if (e.flt_mantissa.flt_h_32 == 0xffffffff) {
e.flt_exp++;
e.flt_mantissa.flt_h_32 = 0x80000000;
}
else e.flt_mantissa.flt_h_32++;
}
else {
e.flt_mantissa.flt_l_32 += 0x80;
}
}
if (e.flt_exp > 255) {
overflow = 1;
e.flt_exp = 255;
e.flt_mantissa.flt_h_32 = e.flt_mantissa.flt_l_32 = 0xffffffff;
}
#endif
buf[I0] = (e.flt_sign << 7) | (e.flt_exp >> 1);
buf[I1] = ((e.flt_exp&1) << 7) |
((e.flt_mantissa.flt_h_32 & 0x7fffffff) >> 24);
buf[I2] = e.flt_mantissa.flt_h_32 >> 16;
buf[I3] = e.flt_mantissa.flt_h_32 >> 8;
#ifndef IEEEFLOAT
if (sz == 8) {
buf[I4] = e.flt_mantissa.flt_h_32;
buf[I5] = e.flt_mantissa.flt_l_32 >> 24;
buf[I6] = e.flt_mantissa.flt_l_32 >> 16;
buf[I7] = e.flt_mantissa.flt_l_32 >> 8;
flt_b64_sft(&(e.flt_mantissa), -56);
}
else
#endif
flt_b64_sft(&(e.flt_mantissa), -24);
#ifdef IEEEFLOAT
}
else {
e.flt_exp += 1023;
if (e.flt_mantissa.flt_h_32 == 0) e.flt_exp = 0;
if (e.flt_mantissa.flt_l_32 & 0x400) {
/* rounding */
if ((e.flt_mantissa.flt_l_32 & 0xfffff800) == 0xfffff800) {
e.flt_mantissa.flt_l_32 = 0;
if (e.flt_mantissa.flt_h_32 == 0xffffffff) {
e.flt_exp++;
e.flt_mantissa.flt_h_32 = 0x80000000;
}
else e.flt_mantissa.flt_h_32++;
}
else {
e.flt_mantissa.flt_l_32 += 0x400;
}
}
if (e.flt_exp >= 2047) {
overflow = 1;
e.flt_exp = 2047;
e.flt_mantissa.flt_h_32 = e.flt_mantissa.flt_l_32 = 0;
}
if (e.flt_exp <= 0) {
flt_b64_sft(&(e.flt_mantissa), 1);
if (e.flt_exp < 0) {
flt_b64_sft(&(e.flt_mantissa), -e.flt_exp);
e.flt_exp = 0;
}
}
buf[I0] = (e.flt_sign << 7) | (e.flt_exp >> 4);
buf[I1] = ((e.flt_exp & 017)<< 4) | ((e.flt_mantissa.flt_h_32 >> 27) & 017);
buf[I2] = e.flt_mantissa.flt_h_32 >> 19;
buf[I3] = e.flt_mantissa.flt_h_32 >> 11;
buf[I4] = e.flt_mantissa.flt_h_32 >> 3;
buf[I5] = (e.flt_mantissa.flt_h_32 << 5) | ((e.flt_mantissa.flt_l_32 >> 27) & 037);
buf[I6] = e.flt_mantissa.flt_l_32 >> 19;
buf[I7] = e.flt_mantissa.flt_l_32 >> 11;
flt_b64_sft(&(e.flt_mantissa), -53);
}
#endif
#if ! FL_MSL_AT_LOW_ADDRESS
if (sz == 4) {
buf[I4] = buf[I0];
buf[I5] = buf[I1];
buf[I6] = buf[I2];
buf[I7] = buf[I3];
}
#endif
if (overflow) {
return 2;
}
return 0;
}
#endif /* USE_FLT */
#ifdef CODE_GENERATOR
con_float()
{
char buf[8];
int rval = float_cst(str, (int)argval, buf);
int i;
if (rval == 1) {
fprintf(stderr,"float constant size = %d\n",(int)argval);
fatal("bad fcon size");
}
fprintf(codefile,"!float %s sz %d\n", str, (int)argval);
if (rval == 2) {
fprintf(stderr, "Warning: overflow in floating point constant %s\n", str);
}
fprintf(codefile, ".data1 0%o", buf[0] & 0377);
for (i = 1; i < (int)argval; i++) {
fprintf(codefile, ",0%o", buf[i] & 0377);
}
putc('\n', codefile);
}
#endif /* CODE_GENERATOR */
#ifdef CODE_EXPANDER
con_float(str, argval)
char *str;
arith argval;
{
char buf[8];
int rval = float_cst(str, (int)argval, buf);
int i;
if (rval == 1) {
argval = 8;
rval = float_cst(str, 8, buf);
}
for (i = 0; i < (int)argval; i++) {
gen1(buf[i]);
}
}
#endif /* CODE_EXPANDER */

175
h/em_table Normal file
View file

@ -0,0 +1,175 @@
magic 173
fmnem 1
nmnem 149
fpseu 150
npseu 30
filb0 180
nilb0 60
fcst0 0
zcst0 120
ncst0 240
fspec 240
nspec 16
ilb1 240
ilb2 241
dlb1 242
dlb2 243
dnam 244
cst2 245
cst4 246
cst8 247
doff 248
pnam 249
scon 250
icon 251
ucon 252
fcon 253
cend 255
bss 0 nvt
con 1 a+
end 2 n?
exa 3 e
exc 4 nn
exp 5 p
hol 6 nvt
ina 7 e
inp 8 p
mes 9 na*
pro 10 pn?
rom 11 a+
aar w- -p-a-p+p
adf w- -a-a+a
adi w- -a-a+a
adp f- -p+p
ads w- -a-p+p
adu w- -a-a+a
and w- -a-a+a
asp f- -a
ass w- -a-x
beq bc -w-w
bge bc -w-w
bgt bc -w-w
ble bc -w-w
blm z- -p-p
bls w- -a-p-p
blt bc -w-w
bne bc -w-w
bra bt 0
cai -p -p
cal pp 0
cff -- -w-w-y+x
cfi -- -w-w-y+x
cfu -- -w-w-y+x
cif -- -w-w-y+x
cii -- -w-w-y+x
ciu -- -w-w-y+x
cmf w- -a-a+w
cmi w- -a-a+w
cmp -- -p-p+w
cms w- -a-a+w
cmu w- -a-a+w
com w- -a-a+a
csa wt -p-a
csb wt -p-a
cuf -- -w-w-y+x
cui -- -w-w-y+x
cuu -- -w-w-y+x
dch -- -p+p
dec -- -w+w
dee g- 0
del l- 0
dup s- -a+a+a
dus w- -a-x+x+x
dvf w- -a-a+a
dvi w- -a-a+a
dvu w- -a-a+a
exg w- -a-a+a+a
fef w- -a+a+w
fif w- -a-a+a+a
fil g- 0
gto gt -p-?
inc -- -w+w
ine g- 0
inl l- 0
inn w- -w-a+w
ior w- -a-a+a
lae g- +p
lal l- +p
lar w- -p-a-p+?
ldc d- +d
lde g- +d
ldf f- -p+d
ldl l- +d
lfr s- +a
lil l- +w
lim -- +w
lin n- 0
lni -- 0
loc c- +w
loe g- +w
lof f- -p+w
loi o- -p+a
lol l- +w
lor r- +p
los w- -a-p+x
lpb -- -p+p
lpi p- +p
lxa n- +p
lxl n- +p
mlf w- -a-a+a
mli w- -a-a+a
mlu w- -a-a+a
mon -- -?+?
ngf w- -a+a
ngi w- -a+a
nop -- 0
rck w- -p-a+a
ret zt -a-?
rmi w- -a-a+a
rmu w- -a-a+a
rol w- -w-a+a
ror w- -w-a+a
rtt -t -?
sar w- -p-a-p-?
sbf w- -a-a+a
sbi w- -a-a+a
sbs w- -p-p+a
sbu w- -a-a+a
sde g- -d
sdf f- -p-d
sdl l- -d
set w- -w+a
sig -- -p-p+p+p
sil l- -w
sim -- -w
sli w- -w-a+a
slu w- -w-a+a
sri w- -w-a+a
sru w- -w-a+a
ste g- -w
stf f- -p-w
sti o- -p-a
stl l- -w
str r- -p
sts w- -a-p-x
teq -- -w+w
tge -- -w+w
tgt -- -w+w
tle -- -w+w
tlt -- -w+w
tne -- -w+w
trp -p -w+?
xor w- -a-a+a
zeq bc -w
zer w- +a
zge bc -w
zgt bc -w
zle bc -w
zlt bc -w
zne bc -w
zre g- 0
zrf w- +a
zrl l- 0