2016-09-17 22:02:16 +00:00
|
|
|
#include "mcg.h"
|
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
static struct e_instr em;
|
2016-09-19 22:19:39 +00:00
|
|
|
static struct basicblock* code_bb;
|
|
|
|
static struct basicblock* data_bb;
|
2016-09-17 22:02:16 +00:00
|
|
|
|
2016-09-19 21:30:41 +00:00
|
|
|
static void queue_insn_label(int opcode, const char* label, arith offset);
|
|
|
|
|
2016-09-17 22:02:16 +00:00
|
|
|
static const char* type_to_str(int type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case EM_MNEM: return "EM_MNEM";
|
|
|
|
case EM_PSEU: return "EM_PSEU";
|
|
|
|
case EM_STARTMES: return "EM_STARTMES";
|
|
|
|
case EM_MESARG: return "EM_MESARG";
|
|
|
|
case EM_ENDMES: return "EM_ENDMES";
|
|
|
|
case EM_DEFILB: return "EM_DEFILB";
|
|
|
|
case EM_DEFDLB: return "EM_DEFDLB";
|
|
|
|
case EM_DEFDNAM: return "EM_DEFDNAM";
|
|
|
|
case EM_ERROR: return "EM_ERROR";
|
|
|
|
case EM_FATAL: return "EM_FATAL";
|
|
|
|
case EM_EOF: return "EM_EOF";
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(0 && "invalid EM type");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* argtype_to_str(int type)
|
|
|
|
{
|
|
|
|
if (type == 0) return "...";
|
|
|
|
if (type == ilb_ptyp) return "ilb";
|
|
|
|
if (type == nof_ptyp) return "nof";
|
|
|
|
if (type == sof_ptyp) return "sof";
|
|
|
|
if (type == cst_ptyp) return "cst";
|
|
|
|
if (type == pro_ptyp) return "pro";
|
|
|
|
if (type == str_ptyp) return "str";
|
|
|
|
if (type == ico_ptyp) return "ico";
|
|
|
|
if (type == uco_ptyp) return "uco";
|
|
|
|
if (type == fco_ptyp) return "fco";
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void unknown_type(const char* s)
|
|
|
|
{
|
|
|
|
fatal("%s with unknown type '%s'",
|
|
|
|
s,
|
2016-09-25 10:29:03 +00:00
|
|
|
argtype_to_str(em.em_arg.ema_argtype));
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char* ilabel_to_str(label l)
|
|
|
|
{
|
2016-09-18 21:24:54 +00:00
|
|
|
assert(current_proc != NULL);
|
2016-09-19 21:06:59 +00:00
|
|
|
return aprintf("__%s_I%d", current_proc->name, l);
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char* dlabel_to_str(label l)
|
|
|
|
{
|
2016-09-18 21:24:54 +00:00
|
|
|
return aprintf("__D%d", l);
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-19 21:30:41 +00:00
|
|
|
static void terminate_block(void)
|
|
|
|
{
|
2016-09-19 22:19:39 +00:00
|
|
|
code_bb->is_terminated = true;
|
|
|
|
code_bb = NULL;
|
2016-09-19 21:30:41 +00:00
|
|
|
}
|
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
static struct em* new_insn(int opcode)
|
2016-09-19 21:06:59 +00:00
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
struct em* em = calloc(sizeof(struct em), 1);
|
|
|
|
em->opcode = opcode;
|
|
|
|
return em;
|
2016-09-19 21:06:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void queue_insn_simple(int opcode)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
struct em* em = new_insn(opcode);
|
|
|
|
em->paramtype = PARAM_NONE;
|
2016-09-26 20:48:58 +00:00
|
|
|
array_append(&code_bb->ems, em);
|
2016-09-19 21:06:59 +00:00
|
|
|
|
|
|
|
switch (opcode)
|
|
|
|
{
|
2016-09-19 21:30:41 +00:00
|
|
|
case op_bra:
|
|
|
|
terminate_block();
|
2016-09-19 21:06:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void queue_insn_value(int opcode, arith value)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
struct em* em = new_insn(opcode);
|
|
|
|
em->paramtype = PARAM_IVALUE;
|
|
|
|
em->u.ivalue = value;
|
2016-09-26 20:48:58 +00:00
|
|
|
array_append(&code_bb->ems, em);
|
2016-09-19 22:19:39 +00:00
|
|
|
|
2016-09-19 21:30:41 +00:00
|
|
|
switch (opcode)
|
|
|
|
{
|
|
|
|
case op_csa:
|
|
|
|
case op_csb:
|
2016-09-22 21:19:29 +00:00
|
|
|
case op_ret:
|
2016-09-19 22:19:39 +00:00
|
|
|
terminate_block();
|
2016-09-19 21:30:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-09-19 21:06:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void queue_insn_label(int opcode, const char* label, arith offset)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
struct em* em = new_insn(opcode);
|
|
|
|
em->paramtype = PARAM_LVALUE;
|
|
|
|
em->u.lvalue.label = label;
|
|
|
|
em->u.lvalue.offset = offset;
|
2016-09-26 20:48:58 +00:00
|
|
|
array_append(&code_bb->ems, em);
|
2016-09-19 22:19:39 +00:00
|
|
|
|
|
|
|
switch (opcode)
|
|
|
|
{
|
|
|
|
case op_bra:
|
|
|
|
terminate_block();
|
|
|
|
break;
|
|
|
|
}
|
2016-09-19 21:06:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void queue_insn_block(int opcode, struct basicblock* left, struct basicblock* right)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
struct em* em = new_insn(opcode);
|
|
|
|
em->paramtype = PARAM_BVALUE;
|
|
|
|
em->u.bvalue.left = left;
|
|
|
|
em->u.bvalue.right = right;
|
2016-09-26 20:48:58 +00:00
|
|
|
array_append(&code_bb->ems, em);
|
2016-09-19 21:06:59 +00:00
|
|
|
|
2016-09-19 21:30:41 +00:00
|
|
|
terminate_block();
|
2016-09-19 21:06:59 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 21:19:29 +00:00
|
|
|
static void change_basicblock(struct basicblock* newbb)
|
|
|
|
{
|
2016-09-26 20:48:58 +00:00
|
|
|
array_appendu(¤t_proc->blocks, newbb);
|
2016-09-22 21:19:29 +00:00
|
|
|
|
|
|
|
if (code_bb && !code_bb->is_terminated)
|
|
|
|
queue_insn_block(op_bra, newbb, NULL);
|
|
|
|
|
|
|
|
code_bb = newbb;
|
|
|
|
}
|
|
|
|
|
2016-09-19 21:06:59 +00:00
|
|
|
static void queue_insn_ilabel(int opcode, int label)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
const char* name = ilabel_to_str(em.em_ilb);
|
2016-09-19 21:06:59 +00:00
|
|
|
struct basicblock* left = bb_get(name);
|
|
|
|
|
|
|
|
switch (opcode)
|
|
|
|
{
|
|
|
|
case op_bra:
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_block(em.em_opcode, left, NULL);
|
2016-09-19 21:06:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case op_zeq:
|
|
|
|
case op_zne:
|
|
|
|
case op_zlt:
|
|
|
|
case op_zle:
|
|
|
|
case op_zgt:
|
|
|
|
case op_zge:
|
2016-10-04 21:28:16 +00:00
|
|
|
case op_beq:
|
|
|
|
case op_bne:
|
|
|
|
case op_blt:
|
|
|
|
case op_ble:
|
|
|
|
case op_bgt:
|
|
|
|
case op_bge:
|
2016-09-22 21:19:29 +00:00
|
|
|
{
|
|
|
|
struct basicblock* bb = bb_get(NULL);
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_block(em.em_opcode, left, bb);
|
2016-09-22 21:19:29 +00:00
|
|
|
change_basicblock(bb);
|
2016-09-19 21:06:59 +00:00
|
|
|
break;
|
2016-09-22 21:19:29 +00:00
|
|
|
}
|
2016-09-19 21:06:59 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
fatal("parse_em: unhandled conditional '%s'",
|
|
|
|
em_mnem[opcode - sp_fmnem]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void queue_ilabel(arith label)
|
|
|
|
{
|
|
|
|
change_basicblock(bb_get(ilabel_to_str(label)));
|
|
|
|
}
|
|
|
|
|
2016-09-17 22:02:16 +00:00
|
|
|
static void parse_pseu(void)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
switch (em.em_opcode)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
|
|
|
case ps_exp: /* external proc */
|
|
|
|
case ps_exa: /* external array */
|
|
|
|
case ps_inp: /* internal proc */
|
|
|
|
case ps_ina: /* internal array */
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
bool export = (em.em_opcode == ps_exp) || (em.em_opcode == ps_exa);
|
|
|
|
bool proc = (em.em_opcode == ps_exp) || (em.em_opcode == ps_inp);
|
2016-09-17 22:02:16 +00:00
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
switch (em.em_arg.ema_argtype)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
|
|
|
case pro_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
symbol_declare(strdup(em.em_pnam), export, proc);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case sof_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
assert(em.em_off == 0);
|
|
|
|
symbol_declare(strdup(em.em_dnam), export, proc);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nof_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
assert(em.em_off == 0);
|
|
|
|
symbol_declare(dlabel_to_str(em.em_dlb), export, proc);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unknown_type("exp, exa, inp, ina");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ps_con: /* .data */
|
|
|
|
case ps_rom: /* .rom */
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
bool ro = (em.em_opcode == ps_rom);
|
2016-09-17 22:02:16 +00:00
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
switch (em.em_arg.ema_argtype)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
|
|
|
case ico_ptyp:
|
|
|
|
case uco_ptyp:
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
arith val = atol(em.em_string);
|
|
|
|
data_int(val, em.em_size, ro);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-10-18 20:29:42 +00:00
|
|
|
case fco_ptyp:
|
|
|
|
{
|
|
|
|
data_float(em.em_string, em.em_size, ro);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-09-17 22:02:16 +00:00
|
|
|
case str_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
data_block(strdup(em.em_string), em.em_size, ro);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case cst_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
data_int(em.em_cst, EM_wordsize, ro);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nof_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
data_offset(dlabel_to_str(em.em_dlb), em.em_off, ro);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
2016-10-15 11:07:59 +00:00
|
|
|
case sof_ptyp:
|
|
|
|
data_offset(strdup(em.em_dnam), em.em_off, ro);
|
|
|
|
break;
|
|
|
|
|
2016-09-17 22:02:16 +00:00
|
|
|
case ilb_ptyp:
|
2016-09-19 22:19:39 +00:00
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
const char* label = ilabel_to_str(em.em_ilb);
|
2016-09-19 22:19:39 +00:00
|
|
|
|
|
|
|
/* This is really hacky; to handle basic block flow
|
|
|
|
* descriptor blocks, we need to track which bbs a descriptor
|
|
|
|
* can exit to. So we create fake bb objects for each
|
|
|
|
* block, purely to track this.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (data_bb)
|
2016-09-23 21:59:15 +00:00
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
struct em* em = new_insn(op_bra);
|
|
|
|
em->paramtype = PARAM_BVALUE;
|
|
|
|
em->u.bvalue.left = bb_get(label);
|
2016-09-26 20:48:58 +00:00
|
|
|
array_append(&data_bb->ems, em);
|
2016-09-23 21:59:15 +00:00
|
|
|
}
|
2016-09-19 22:19:39 +00:00
|
|
|
|
|
|
|
data_offset(label, 0, ro);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
2016-09-19 22:19:39 +00:00
|
|
|
}
|
2016-09-17 22:02:16 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
unknown_type("con, rom");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ps_bss:
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
switch (em.em_arg.ema_argtype)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
|
|
|
case cst_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
data_bss(EM_bsssize, em.em_cst);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
2016-10-15 11:07:59 +00:00
|
|
|
case ico_ptyp:
|
|
|
|
case uco_ptyp:
|
|
|
|
{
|
|
|
|
arith val = atol(em.em_string);
|
|
|
|
data_int(val, em.em_size, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case sof_ptyp:
|
|
|
|
data_offset(strdup(em.em_dnam), em.em_off, false);
|
|
|
|
break;
|
|
|
|
|
2016-09-17 22:02:16 +00:00
|
|
|
default:
|
|
|
|
unknown_type("bss");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ps_pro: /* procedure start */
|
2016-09-23 23:04:00 +00:00
|
|
|
{
|
|
|
|
struct symbol* symbol;
|
|
|
|
|
2016-09-19 21:06:59 +00:00
|
|
|
current_proc = calloc(sizeof(struct procedure), 1);
|
2016-09-25 10:29:03 +00:00
|
|
|
current_proc->name = strdup(em.em_pnam);
|
2016-10-15 16:38:46 +00:00
|
|
|
current_proc->entry = bb_get(current_proc->name);
|
2016-10-15 20:53:56 +00:00
|
|
|
current_proc->locals_size = em.em_nlocals;
|
2016-10-15 16:38:46 +00:00
|
|
|
code_bb = current_proc->entry;
|
2016-09-19 22:19:39 +00:00
|
|
|
code_bb->is_root = true;
|
2016-09-26 20:48:58 +00:00
|
|
|
array_append(¤t_proc->blocks, code_bb);
|
2016-09-23 23:04:00 +00:00
|
|
|
|
|
|
|
symbol = symbol_get(current_proc->name);
|
|
|
|
symbol->section = SECTION_TEXT;
|
|
|
|
symbol->proc = current_proc;
|
|
|
|
symbol->is_proc = true;
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
2016-09-23 23:04:00 +00:00
|
|
|
}
|
2016-09-17 22:02:16 +00:00
|
|
|
|
|
|
|
case ps_end: /* procedure end */
|
2016-10-15 21:19:44 +00:00
|
|
|
tb_procedure();
|
2016-09-19 21:06:59 +00:00
|
|
|
|
2016-09-18 21:24:54 +00:00
|
|
|
current_proc = NULL;
|
2016-09-19 22:19:39 +00:00
|
|
|
code_bb = NULL;
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-09-25 10:29:03 +00:00
|
|
|
fatal("unknown pseudo with opcode %d\n", em.em_opcode);
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static arith mes_get_cst(void)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
EM_getinstr(&em);
|
|
|
|
if (em.em_type != EM_MESARG)
|
2016-09-17 22:02:16 +00:00
|
|
|
fatal("malformed MES");
|
2016-09-25 10:29:03 +00:00
|
|
|
return em.em_cst;
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void parse_mes(void)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
assert(em.em_arg.ema_argtype == cst_ptyp);
|
|
|
|
switch (em.em_cst)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
|
|
|
case 0: /* error */
|
|
|
|
fatal("MES 0 received (explicit halt)");
|
|
|
|
|
|
|
|
case 3: /* register variable */
|
|
|
|
{
|
2016-10-01 21:13:39 +00:00
|
|
|
/* ego will sometimes generate 'mes 3' pseudos with no actual
|
|
|
|
* parameters. Detect and ignore these. */
|
|
|
|
|
|
|
|
EM_getinstr(&em);
|
|
|
|
if (em.em_type == EM_MESARG)
|
|
|
|
{
|
|
|
|
arith offset = em.em_cst;
|
|
|
|
int size = mes_get_cst();
|
|
|
|
int type = mes_get_cst();
|
|
|
|
int priority = mes_get_cst();
|
2016-10-01 22:30:33 +00:00
|
|
|
tb_regvar(current_proc, offset, size, type, priority);
|
2016-10-01 21:13:39 +00:00
|
|
|
}
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
while ((em.em_type == EM_STARTMES) || (em.em_type == EM_MESARG))
|
|
|
|
EM_getinstr(&em);
|
2016-09-17 22:02:16 +00:00
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
if (em.em_type != EM_ENDMES)
|
2016-09-17 22:02:16 +00:00
|
|
|
fatal("malformed MES");
|
|
|
|
}
|
|
|
|
|
2016-09-23 23:04:00 +00:00
|
|
|
static void create_data_label(const char* label)
|
|
|
|
{
|
|
|
|
data_label(label);
|
|
|
|
if (current_proc)
|
|
|
|
{
|
|
|
|
data_bb = bb_get(label);
|
|
|
|
data_bb->is_fake = true;
|
2016-09-26 20:48:58 +00:00
|
|
|
array_append(¤t_proc->blocks, data_bb);
|
2016-09-23 23:04:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-17 22:02:16 +00:00
|
|
|
void parse_em(void)
|
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
EM_getinstr(&em);
|
2016-09-17 22:02:16 +00:00
|
|
|
tb_filestart();
|
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
while (em.em_type != EM_EOF)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
switch (em.em_type)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
|
|
|
case EM_PSEU:
|
|
|
|
parse_pseu();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EM_DEFILB:
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_ilabel(em.em_ilb);
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EM_DEFDLB:
|
2016-09-25 10:29:03 +00:00
|
|
|
create_data_label(dlabel_to_str(em.em_dlb));
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EM_DEFDNAM:
|
2016-09-25 10:29:03 +00:00
|
|
|
create_data_label(strdup(em.em_dnam));
|
2016-09-17 22:02:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EM_STARTMES:
|
|
|
|
parse_mes();
|
2016-09-18 21:24:54 +00:00
|
|
|
break;
|
2016-09-17 22:02:16 +00:00
|
|
|
|
|
|
|
case EM_MNEM:
|
2016-09-19 22:19:39 +00:00
|
|
|
if (code_bb)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
int flags = em_flag[em.em_opcode - sp_fmnem];
|
2016-09-19 21:06:59 +00:00
|
|
|
|
|
|
|
if (flags & EM_PAR)
|
2016-09-17 22:02:16 +00:00
|
|
|
{
|
2016-09-25 10:29:03 +00:00
|
|
|
switch (em.em_argtype)
|
2016-09-19 21:06:59 +00:00
|
|
|
{
|
|
|
|
case ilb_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_ilabel(em.em_opcode, em.em_ilb);
|
2016-09-19 21:06:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nof_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_label(em.em_opcode,
|
|
|
|
dlabel_to_str(em.em_dlb), em.em_off);
|
2016-09-19 21:06:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case sof_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_label(em.em_opcode,
|
|
|
|
strdup(em.em_dnam), em.em_off);
|
2016-09-19 21:06:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case pro_ptyp:
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_label(em.em_opcode,
|
|
|
|
strdup(em.em_pnam), 0);
|
2016-09-19 21:06:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case cst_ptyp:
|
|
|
|
if ((flags & EM_PAR) == PAR_B)
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_ilabel(em.em_opcode, em.em_ilb);
|
2016-09-19 21:06:59 +00:00
|
|
|
else
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_value(em.em_opcode, em.em_cst);
|
2016-09-19 21:06:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unknown_type("instruction");
|
|
|
|
}
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
2016-09-19 21:06:59 +00:00
|
|
|
else
|
2016-09-25 10:29:03 +00:00
|
|
|
queue_insn_simple(em.em_opcode);
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-09-25 10:29:03 +00:00
|
|
|
fatal("unrecognised instruction type '%d'", em.em_type);
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
EM_getinstr(&em);
|
2016-09-17 22:02:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tb_fileend();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set sw=4 ts=4 expandtab : */
|