completely new version

This commit is contained in:
ceriel
1987-11-12 11:59:31 +00:00
parent f9281be252
commit 0baf75f779
52 changed files with 975 additions and 116 deletions

173
modules/src/em_code/C_out.c Normal file
View File

@@ -0,0 +1,173 @@
#include <em.h>
#include <em_comp.h>
#include <em_pseu.h>
#include <em_flag.h>
#include <em_ptyp.h>
#include <em_private.h>
static arg();
static pseudo();
extern char em_flag[];
struct e_instr *
C_alloc()
{
static struct e_instr b;
return &b;
}
C_out(p)
register struct e_instr *p;
{
/* Generate EM-code from the e_instr structure "p"
*/
switch(p->em_type) {
case EM_MNEM:
OP(p->em_opcode);
if (em_flag[p->em_opcode] == PAR_B) {
p->em_argtype = ilb_ptyp;
p->em_ilb = p->em_cst;
}
if (em_flag[p->em_opcode] != PAR_NO) arg(p, 0);
NL();
break;
case EM_PSEU:
pseudo(p);
break;
case EM_STARTMES:
PS(ps_mes);
CST(p->em_cst);
break;
case EM_MESARG:
arg(p, 1);
break;
case EM_ENDMES:
CEND();
NL();
break;
case EM_DEFILB:
DFILB(p->em_ilb);
NL();
break;
case EM_DEFDLB:
DFDLB(p->em_dlb);
NL();
break;
case EM_DEFDNAM:
DFDNAM(p->em_dnam);
NL();
break;
}
}
static
arg(p, comma)
register struct e_instr *p;
{
/* Output the argument of "p".
*/
if (comma) COMMA();
switch(p->em_argtype) {
case 0:
CCEND();
break;
case ilb_ptyp:
ILB(p->em_ilb);
break;
case nof_ptyp:
DOFF(p->em_dlb, p->em_off);
break;
case sof_ptyp:
NOFF(p->em_dnam, p->em_off);
break;
case cst_ptyp:
CST(p->em_cst);
break;
case pro_ptyp:
PNAM(p->em_pnam);
break;
case str_ptyp:
SCON(p->em_string, p->em_size);
break;
case ico_ptyp:
WCON(sp_icon, p->em_string, p->em_size);
break;
case uco_ptyp:
WCON(sp_ucon, p->em_string, p->em_size);
break;
case fco_ptyp:
WCON(sp_fcon, p->em_string, p->em_size);
break;
}
}
static
pseudo(p)
register struct e_instr *p;
{
PS(p->em_opcode);
switch(p->em_opcode) {
case ps_exc:
CST(p->em_exc1);
COMMA();
CST(p->em_exc2);
break;
case ps_rom:
case ps_con:
arg(p, 0);
CEND();
break;
case ps_bss:
case ps_hol:
CST(EM_holsize);
arg(p, 1);
COMMA();
CST((arith) EM_holinit);
break;
case ps_pro:
arg(p, 0);
COMMA();
if (p->em_nlocals != -1) CST(p->em_nlocals);
else CCEND();
break;
case ps_end:
if (p->em_argtype == 0) CCEND();
else CST(p->em_cst);
break;
default:
arg(p, 0);
break;
}
NL();
}