ack/mach/z80/as/mach5.c

65 lines
1.2 KiB
C
Raw Permalink Normal View History

1987-03-09 19:15:41 +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".
*/
1994-06-24 14:02:31 +00:00
#define RCSID5 "$Id$"
1985-06-10 16:57:01 +00:00
/*
* Zilog Z80 special routines
*/
2019-03-24 16:14:27 +00:00
void xyreg(int r,int byte)
{
1985-06-10 16:57:01 +00:00
if (r==IX)
emit1(0335);
else if (r==IY)
emit1(0375);
else if (r!=HL)
serror("register error");
emit1(byte);
}
2019-03-24 16:14:27 +00:00
void xymem(int r,int byte)
{
1985-06-10 16:57:01 +00:00
xyreg(r,byte);
if (r != HL) {
#ifdef RELOCATION
RELOMOVE(relonami, rel_ind);
newrelo(exp_ind.typ, RELO1);
#endif
emit1(exp_ind.val);
}
}
2019-03-24 16:14:27 +00:00
void branch(register int opc,expr_t exp)
{
register int sm,dist;
1985-06-10 16:57:01 +00:00
dist = exp.val - (DOTVAL + 2);
if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
dist -= DOTGAIN;
sm = fitb(dist);
if ((exp.typ & ~S_DOT) != DOTTYP)
sm = 0;
if (opc == 020) { /* DJNZ must be short */
fit(sm);
sm = 1;
} else if ((sm = small(sm,1)) == 0) {
if (opc == 030) /* 'JR exp' */
opc = 0303; /* replace by 'JP exp' */
else /* 'JR CC,exp' */
opc ^= 0342; /* replace by 'JP CC,exp' */
}
emit1(opc);
if (sm == 0) {
#ifdef RELOCATION
newrelo(exp.typ, RELO2);
1985-06-10 16:57:01 +00:00
#endif
emit2(exp.val);
} else {
emit1(lowb(dist));
}
}