📄 outc30_r.c
字号:
return 3; case en_nacon: return 3; case en_add: return 4; case en_sub: return 5; case en_cast: return testconst (ep->v.p[0]); case en_uminus: return -testconst (ep->v.p[0]); default: return 99; }}#ifdef DEBUGvoid putamode_tst P1 (const ADDRESS *, ap){ FHANDLE save = output; output = debugfile; putamode (ap); output = save;}void putreg_tst P1 (REG, reg){ FHANDLE save = output; output = debugfile; putreg (reg); output = save;}#endif /* DEBUG *//* * output a general addressing mode. */static void putamode P1 (const ADDRESS *, ap){ switch (ap->mode) { case am_const_direct:#ifdef DEBUG if (is_debugging (DEBUG_CODE) || is_debugging (DEBUG_FLOW)) { oprintf ("(const)"); }#endif /* DEBUG */ /*lint -fallthrough */ case am_direct: oprintf ("@"); /*lint -fallthrough */ case am_immed: putconst (ap->u.offset); break; case am_areg: case am_dreg: case am_ireg: case am_sreg: case am_freg: putreg (ap->preg); break; case am_const_ind:#ifdef DEBUG if (is_debugging (DEBUG_CODE) || is_debugging (DEBUG_FLOW)) { oprintf ("(const)"); }#endif /* DEBUG */ /*lint -fallthrough */ case am_ind: oprintf ("*ar%d", (int) ap->preg - REG_AR0); break; case am_ainc: oprintf ("*ar%d++(", (int) ap->preg - REG_AR0); putconst (ap->u.offset); oprintf (")"); break; case am_adec: oprintf ("*ar%d--(", (int) ap->preg - REG_AR0); putconst (ap->u.offset); oprintf (")"); break; case am_preinc: oprintf ("*++ar%d(", (int) ap->preg - REG_AR0); putconst (ap->u.offset); oprintf (")"); break; case am_predec: oprintf ("*--ar%d(", (int) ap->preg - REG_AR0); putconst (ap->u.offset); oprintf (")"); break; case am_indx: if (testconst (ap->u.offset) >= 0) { oprintf ("*+ar%d(", (int) ap->preg - REG_AR0); putconst (ap->u.offset); } else { oprintf ("*-ar%d(", (int) ap->preg - REG_AR0); putconstneg (ap->u.offset); } oprintf (")"); break; case am_indx2: oprintf ("*+ar%d(ir%d)", (int) ap->preg - REG_AR0, (int) ap->sreg - REG_IR0); break; case am_indxs: oprintf ("*-ar%d(ir%d)", (int) ap->preg - REG_AR0, (int) ap->sreg - REG_IR0); break; case am_line: case am_str: putconst (ap->u.offset); break; default: FATAL ((__FILE__, "putamode", "illegal address mode %d", ap->mode)); break; }}/* * Following function is only used for debugging-purpose */#if defined(FAST_PEEP) && !defined(SAVE_PEEP_MEMORY)static void put_peepinfo (PEEPINFO *info){ oprintf ("\t"); if (info != NULL) { oprintf ("r:%08X ", info->read); oprintf ("w:%08X ", info->write); oprintf ("m:%08X ", info->modified); oprintf ("us:%08X ", info->used); oprintf ("up:%08X", info->updated); } else { oprintf ("<NoPeepinfo>"); }}/* #define PUT_PEEPINFO(info) put_peepinfo(info) */#define PUT_PEEPINFO(info)#else#define PUT_PEEPINFO(info)#endif/* * output a generic instruction. */PRIVATE void put_code P1 (const CODE *, ip){ if (ip->opcode < OP_PARALLEL_FIRST) { putop (ip->opcode); if (ip->src1 != NIL_ADDRESS) { oprintf ("\t"); putamode (ip->src1); if (ip->src2 != NIL_ADDRESS) { oprintf (","); putamode (ip->src2); } if (ip->dst != NIL_ADDRESS) { oprintf (","); putamode (ip->dst); } } else if (ip->dst != NIL_ADDRESS) { oprintf ("\t"); putamode (ip->dst); } PUT_PEEPINFO (ip->info); oprintf ("%s", newline); } else if (ip->opcode <= op_xor3_sti) { putop (ParallelOp[ip->opcode - OP_PARALLEL_FIRST][0]); /*lint !e656*/ /*arithmetic operation uses compatible enum's */ if (ip->src1 != NIL_ADDRESS) { oprintf ("\t"); putamode (ip->src1); if (ip->src2 != NIL_ADDRESS) { oprintf (","); putamode (ip->src2); } if (ip->dst != NIL_ADDRESS) { oprintf (","); putamode (ip->dst); } } oprintf ("%s|| ", newline); putop (ParallelOp[ip->opcode - OP_PARALLEL_FIRST][1]); /*lint !e656*/ /*arithmetic operation uses compatible enum's */ if (ip->src21 != NIL_ADDRESS) { oprintf ("\t"); putamode (ip->src21); if (ip->src22 != NIL_ADDRESS) { oprintf (","); putamode (ip->src22); } if (ip->dst2 != NIL_ADDRESS) { oprintf (","); putamode (ip->dst2); } } PUT_PEEPINFO (ip->info); oprintf ("%s", newline);#ifdef ASM } else if (ip->opcode == op_asm) { /*oprintf ("\t"); we cannot output labels if tab is there */ putamode (ip->src1); PUT_PEEPINFO (ip->info); oprintf ("\n");#endif } else if (ip->opcode == op_line) { oprintf ("\n*>>>> line "); putamode (ip->src1); oprintf (": "); putamode (ip->src2); PUT_PEEPINFO (ip->info); oprintf ("%s%s", newline, newline); } else { FATAL ((__FILE__, "put_code", "illegal op %d", ip->opcode)); }}/* * generate a register name */static void putreg P1 (REG, r){ static const char *regname[] = { "r0", /* REG_R0 */ "r1", /* REG_R1 */ "r2", /* REG_R2 */ "r3", /* REG_R3 */ "r4", /* REG_R4 */ "r5", /* REG_R5 */ "r6", /* REG_R6 */ "r7", /* REG_R7 */ "ar0", /* REG_AR0 */ "ar1", /* REG_AR1 */ "ar2", /* REG_AR2 */ "ar3", /* REG_AR3 */ "ar4", /* REG_AR4 */ "ar5", /* REG_AR5 */ "ar6", /* REG_AR6 */ "ar7", /* REG_AR7 */ "dp", /* REG_DP */ "ir0", /* REG_IR0 */ "ir1", /* REG_IR1 */ "bk", /* REG_BK */ "sp", /* REG_SP */ "st", /* REG_ST */ "ie", /* REG_IE */ "if", /* REG_IF */ "iof", /* REG_IOF */ "rs", /* REG_RS */ "re", /* REG_RE */ "rc" /* REG_RC */ }; if (r >= REG_R0 && r <= REG_RC) { oprintf ("%s", regname[r]); } else { oprintf ("R%d??", (int) r); }}/* * generate a named label. */PRIVATE void put_name P1 (SYM *, sp){ put_reference (sp); oprintf ("%s:%s", outlate (sp->name), newline);}/* * output a compiler generated label. */PRIVATE void put_label P1 (LABEL, lab){ oprintf ("%s%u:%s", prefix, (unsigned int) lab, newline);}static void put_header P2 (enum e_gt, gtype, SIZE, al){ static const char *directive[] = { ".word \t", /* bytegen */ ".word \t", /* wordgen */ ".word \t", /* longgen */ ".word \t", /* longlonggen */ ".float\t", /* floatgen */ }; if (gentype != gtype || outcol >= MAX_WIDTH) { put_align (al); gentype = gtype; outcol = 15; oprintf ("\t%s", directive[gtype]); } else oprintf (",");}PRIVATE void put_byte P1 (UVAL, val){ put_header (bytegen, alignment_of_type (tp_char)); oprintf ("0%lxh", val & OxffUL); outcol += 5;}PRIVATE void put_word P1 (UVAL, val){ put_header (wordgen, alignment_of_type (tp_short)); oprintf ("0%lxh", val & OxffffUL); outcol += 7;}#ifdef FLOAT_SUPPORTPRIVATE void put_float P1 (const RVAL *, vp){ put_header (floatgen, alignment_of_type (tp_float)); oprintf ("%f", *vp); outcol += 80;}PRIVATE void put_double P1 (const RVAL *, vp){ put_header (floatgen, alignment_of_type (tp_double)); oprintf ("%f", *vp); outcol += 80;}PRIVATE void put_longdouble P1 (const RVAL *, vp){ put_header (floatgen, alignment_of_type (tp_longdouble)); oprintf ("%f", *vp); outcol += 80;}#endif /* FLOAT_SUPPORT */PRIVATE void put_dword P1 (UVAL, val){ put_header (longgen, alignment_of_type (tp_long)); oprintf ("0%lxh", val); outcol += 11;}#ifndef RELOC_BUGPRIVATE void put_char P1 (const EXPR *, ep){ put_header (bytegen, alignment_of_type (tp_char)); putconst (ep); outcol += 10;}PRIVATE void put_short P1 (const EXPR *, ep){ put_header (wordgen, alignment_of_type (tp_short)); putconst (ep); outcol += 10;}#endif /* RELOC_BUG */PRIVATE void put_long P1 (const EXPR *, ep){ put_header (longgen, alignment_of_type (tp_long)); putconst (ep); outcol += 10;}PRIVATE void put_longlong P1 (const EXPR *, ep){ put_header (longlonggen, alignment_of_type (tp_longlong)); putconst (ep); outcol += 10;}PRIVATE void put_pointer P1 (const EXPR *, ep){ put_header (longgen, alignment_of_type (tp_pointer)); putconst (ep); outcol += 10;}PRIVATE void put_storage P1 (const SYM *, sp){ nl (); oprintf ("\t.bss "); /*bseg(); */ if (sp->storage_class == sc_static) { oprintf ("%s%u", prefix, (unsigned int) sp->value.l); } else { oprintf ("%s", outlate (sp->name)); } oprintf (", %ld%s", sp->tp->size, newline);}/* * dump the string literal pool. * if we are producing single copies of strings (which should therefore * be read only we put them in the text segement - else in the data segment. */PRIVATE void put_literals P0 (void){ const CHAR *cp; size_t len; if (lang_option == LANG_KANDR) { put_dseg (alignment_of_type (tp_char)); } else { put_rseg (alignment_of_type (tp_char)); } for (; strtab != (struct slit *) NULL; strtab = strtab->next) { nl (); put_label (strtab->label); cp = strtab->str; for (len = strtab->len; len--;) put_byte ((UVAL) *cp++); put_byte ((UVAL) 0); nl (); } nl ();}/* put the definition of an external name in the ouput file */PRIVATE void put_reference P1 (SYM *, sp){ if (!is_symbol_output (sp)) { switch (sp->storage_class) { case sc_global: nl (); oprintf ("\t.global %s%s", outlate (sp->name), newline); break; case sc_external: nl (); oprintf ("\t.global %s%s", outlate (sp->name), newline); break; default: break; } symbol_output (sp);
}}/* align the following data */PRIVATE void put_align P1 (SIZE, al){ nl (); if (al > align_type) { switch (al) { case 1: break; case 2: case 4: oprintf ("\t.even%s", newline); break; default: break; } } align_type = al;}/* * output any function epilogue code */PRIVATE void put_epilogue P2 (SYM *, sp, LABEL, label){ sp = sp; /* keep the compiler quiet */ label = label; /* keep the compiler quiet */}PRIVATE void nl P0 (void){ if (outcol > 0) { oprintf ("%s", newline); gentype = nogen; outcol = 0; }}static void seg P3 (enum e_sg, segtype, const char *, segname, SIZE, al){ nl (); if (curseg != segtype) { oprintf ("\t%s%s", segname, newline); curseg = segtype; align_type = 0; } put_align (al);}PRIVATE void put_cseg P1 (SIZE, al){ seg (codeseg, ".text", al);}PRIVATE void put_dseg P1 (SIZE, al){ seg (dataseg, ".data", al);}PRIVATE void put_kseg P1 (SIZE, al){ seg (constseg, ".sect \".const\"", al);}PRIVATE void put_rseg P1 (SIZE, al){ seg (romseg, ".sect \".rom\"", al);}PRIVATE void put_finish P0 (void){}PRIVATE void put_start P0 (void){ oprintf ("%s Generated by %s %s %s (%s) from \"%s\"%s", comment, PROGNAME, VERSION, LAST_CHANGE_DATE, __DATE__, in_file, newline);#ifdef VERBOSE { time_t time_of_day; VOIDCAST time (&time_of_day); oprintf ("%s Compilation date/time: %s%s", comment, ctime (&time_of_day), newline); }#endif /* VERBOSE */ /* introduce the sections */ seg (codeseg, ".text", 0L); seg (romseg, ".sect \".rom\"", 0L); seg (dataseg, ".data", 0L); /*seg(bssseg, ".bss", 0L); */ /* Do some consistency-check in opcodetable */ /* checks only size, but proved to be usefull */ assert (((sizeof (opl) / sizeof (opl[0])) - 1) == (OP_MAX - OP_MIN)); /*lint !e656*/ /*arithmetic operation uses compatible enum's */}#ifdef MULTIPLE_ASSEMBLERSstruct funcs rosc30_funcs = { put_code, put_name, put_label, put_byte, put_word, put_dword,#ifndef RELOC_BUG put_char, put_short,#endif /* RELOC_BUG */ put_long, put_longlong, put_pointer, put_storage, put_literals, put_finish, put_start, put_reference, put_epilogue, put_cseg, put_dseg, put_kseg, put_rseg, #ifndef FLOAT_BOOTSTRAP#ifdef FLOAT_SUPPORT put_float, put_double, put_longdouble,#endif /* FLOAT_SUPPORT */#endif /* FLOAT_BOOTSTRAP */ NULL};#endif /* MULTIPLE_ASSEMBLERS */#endif /* TARGET_ROSSIN */#endif /* TMS320C30 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -