2024-02-22 15:13:52 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
encode_imm(int opc, int sz, expr_t exp)
|
|
|
|
{
|
|
|
|
emit1(opc);
|
|
|
|
emit1(sz);
|
|
|
|
switch(sz)
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
case 0:
|
|
|
|
emit1(exp.val);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
case 1:
|
|
|
|
emit2(exp.val);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
emit4(exp.val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-22 19:37:12 +00:00
|
|
|
void branch(register int opc, expr_t exp)
|
2024-02-22 15:13:52 +00:00
|
|
|
{
|
2024-02-22 19:37:12 +00:00
|
|
|
register int dist;
|
2024-02-22 15:13:52 +00:00
|
|
|
|
|
|
|
dist = exp.val - (DOTVAL + 2);
|
|
|
|
if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
|
|
|
|
dist -= DOTGAIN;
|
2024-02-22 19:37:12 +00:00
|
|
|
if (small(fitb(dist) && (exp.typ & ~S_DOT) == DOTTYP, 3)) {
|
|
|
|
emit1(opc); emit1(dist);
|
2024-02-22 15:13:52 +00:00
|
|
|
} else {
|
2024-02-22 19:37:12 +00:00
|
|
|
emit1(opc^0x20); emit1(0x03); /* Skip over ... */
|
|
|
|
emit1(0x4C); /* ... far jump. */
|
2024-02-22 15:13:52 +00:00
|
|
|
#ifdef RELOCATION
|
2024-02-22 19:37:12 +00:00
|
|
|
newrelo(exp.typ, RELO2);
|
2024-02-22 15:13:52 +00:00
|
|
|
#endif
|
2024-02-22 19:37:12 +00:00
|
|
|
emit2(exp.val);
|
2024-02-22 15:13:52 +00:00
|
|
|
}
|
|
|
|
}
|