1994-06-24 14:02:31 +00:00
|
|
|
#define RCSID5 "$Id$"
|
1987-02-26 19:46:35 +00:00
|
|
|
|
|
|
|
/*
|
1987-03-10 01:26:51 +00:00
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
1987-02-26 19:46:35 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
op1(mode) {
|
|
|
|
int relpc = 0;
|
|
|
|
if (im1flag) {
|
|
|
|
if (mode == 067 || mode == 077) {
|
|
|
|
exp_1.val = adjust(exp_1);
|
|
|
|
relpc = RELPC;
|
|
|
|
}
|
|
|
|
#ifdef RELOCATION
|
|
|
|
RELOMOVE(relonami, rel_1);
|
|
|
|
if (rflag != 0 && PASS_RELO)
|
|
|
|
newrelo(exp_1.typ, RELO2|relpc);
|
|
|
|
#endif
|
|
|
|
emit2(exp_1.val);
|
|
|
|
im1flag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
op2(mode) {
|
|
|
|
int relpc = 0;
|
|
|
|
if (im2flag) {
|
|
|
|
if (mode == 067 || mode == 077) {
|
|
|
|
relpc = RELPC;
|
|
|
|
exp_2.val = adjust(exp_2);
|
|
|
|
}
|
|
|
|
#ifdef RELOCATION
|
|
|
|
RELOMOVE(relonami, rel_2);
|
|
|
|
if (rflag != 0 && PASS_RELO)
|
|
|
|
newrelo(exp_2.typ, RELO2|relpc);
|
|
|
|
#endif
|
|
|
|
emit2(exp_2.val);
|
|
|
|
im2flag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
branch(opc,exp) expr_t exp; {
|
|
|
|
register eval;
|
|
|
|
register sm;
|
|
|
|
|
|
|
|
eval = adjust(exp) >> 1;
|
|
|
|
sm = fitb(eval);
|
|
|
|
if ((exp.typ & ~S_DOT) != DOTTYP && pass >= PASS_2) sm = 0;
|
|
|
|
if (!sm && pass >= PASS_2) {
|
|
|
|
serror("label too far");
|
|
|
|
}
|
|
|
|
emit2(opc | lowb(eval));
|
|
|
|
}
|
|
|
|
|
|
|
|
ejump(opc, exp) expr_t exp; {
|
|
|
|
register sm,eval;
|
|
|
|
int gain;
|
|
|
|
|
|
|
|
# ifdef THREE_PASS
|
|
|
|
eval = adjust(exp) >> 1;
|
|
|
|
sm = fitb(eval);
|
|
|
|
if ((exp.typ & ~S_DOT) != DOTTYP) {
|
|
|
|
sm = 0;
|
|
|
|
}
|
|
|
|
gain = (opc == OPBRA ? 2 : 4);
|
|
|
|
if (small(sm,gain)) {
|
|
|
|
emit2( opc | lowb(eval));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# endif
|
|
|
|
if (opc != OPBRA) {
|
1987-05-20 17:15:22 +00:00
|
|
|
emit2((opc^0400) | 02);
|
1987-02-26 19:46:35 +00:00
|
|
|
}
|
|
|
|
|
1987-05-18 10:40:19 +00:00
|
|
|
exp_1 = exp;
|
1987-02-26 19:46:35 +00:00
|
|
|
im1flag = 1;
|
1987-05-26 15:35:17 +00:00
|
|
|
emit2(0100|067);
|
1987-05-26 15:31:43 +00:00
|
|
|
op1(067);
|
1987-02-26 19:46:35 +00:00
|
|
|
# ifdef THREE_PASS
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
}
|
|
|
|
|
|
|
|
sob(reg, exp) expr_t exp; {
|
|
|
|
if ((exp.typ & ~S_DOT) != DOTTYP) {
|
|
|
|
serror("error in sob-label");
|
|
|
|
}
|
|
|
|
exp.val = ( - adjust(exp) ) >> 1;
|
|
|
|
fit(fit6(exp.val));
|
|
|
|
emit2( OPSOB | (reg << 6) | exp.val);
|
|
|
|
}
|
|
|
|
|
|
|
|
jump(opc,opr) {
|
|
|
|
register val;
|
|
|
|
|
|
|
|
# ifdef THREE_PASS
|
1987-05-15 16:31:00 +00:00
|
|
|
if (opr==067) {
|
|
|
|
register sm = 0;
|
|
|
|
|
1987-02-26 19:46:35 +00:00
|
|
|
val = adjust(exp_1) >> 1;
|
|
|
|
if ( fitb(val) && (exp_1.typ & ~S_DOT) == DOTTYP) {
|
|
|
|
sm = 1;
|
|
|
|
}
|
|
|
|
if (small(sm,2)) {
|
|
|
|
emit2(OPBRA | lowb(val));
|
|
|
|
im1flag = 0;
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
1987-05-15 16:31:00 +00:00
|
|
|
# endif
|
1987-02-26 19:46:35 +00:00
|
|
|
emit2(opc | opr);
|
|
|
|
op1(opr);
|
|
|
|
}
|
|
|
|
|
|
|
|
valu_t adjust(exp) expr_t exp; {
|
|
|
|
valu_t val;
|
|
|
|
|
|
|
|
val = exp.val - DOTVAL - 2;
|
|
|
|
# ifdef THREE_PASS
|
|
|
|
if (pass == PASS_2 && val > 0) val -= DOTGAIN;
|
|
|
|
# endif
|
|
|
|
return(val);
|
|
|
|
}
|