void GenPreIdentAccess(int label) { if (UseGp) return; printf2("\t.set\tnoat\n\tlui\t$1, %%hi("); GenPrintLabel(IdentTable + label); puts2(")"); }
void GenAddrData(int Size, char* Label) { if (Size == 1) printf2("\t.byte\t"); else if (Size == 2) printf2("\t.half\t"); else if (Size == 4) printf2("\t.word\t"); GenPrintLabel(Label); puts2(""); }
void strerr_warn(const char *x1,const char *x2,const char *x3,const char *x4,const char *x5,const char *x6,const struct strerr *se) { strerr_sysinit(); if (x1) puts2(x1); if (x2) puts2(x2); if (x3) puts2(x3); if (x4) puts2(x4); if (x5) puts2(x5); if (x6) puts2(x6); while(se) { if (se->x) puts2(se->x); if (se->y) puts2(se->y); if (se->z) puts2(se->z); se = se->who; } puts2("\n"); buffer_flush(buffer_2); }
STATIC void GenAddrData(int Size, char* Label, int ofs) { ofs = truncInt(ofs); if (Size == 1) printf2("\t.db\t"); else if (Size == 2) printf2("\t.dw\t"); else if (Size == 4) printf2("\t.dd\t"); GenPrintLabel(Label); if (ofs) printf2(" %+d", ofs); puts2(""); }
void GenFin(void) { if (StructCpyLabel) { char s[1 + 2 + (2 + CHAR_BIT * sizeof StructCpyLabel) / 3]; char *p = s + sizeof s; int lbl = LabelCnt++; *--p = '\0'; p = lab2str(p, StructCpyLabel); *--p = '_'; *--p = '_'; if (OutputFormat != FormatFlat) puts2(CodeHeader); GenLabel(p, 1); puts2("\tmove\t$2, $6\n" "\tmove\t$3, $6"); GenNumLabel(lbl); puts2("\tlbu\t$6, 0($5)\n" "\taddiu\t$5, $5, 1\n" "\taddiu\t$4, $4, -1\n" "\tsb\t$6, 0($3)\n" "\taddiu\t$3, $3, 1"); printf2("\tbne\t$4, $0, "); GenPrintNumLabel(lbl); puts2(""); #ifndef NO_REORDER_WORKAROUND GenNop(); #endif puts2("\tj\t$31"); #ifndef NO_REORDER_WORKAROUND GenNop(); #endif if (OutputFormat != FormatFlat) puts2(CodeFooter); } }
void GenPostIdentAccess(void) { if (UseGp) return; puts2("\t.set\tat"); }
void GenPrintNewLine(void) { puts2(""); }
void GenNop(void) { puts2("\tnop"); }
unsigned GenStrData(int generatingCode, unsigned requiredLen) { int i; unsigned total = 0; // insert string literals into the code for (i = 0; i < sp; i++) { int tok = stack[i][0]; char* p = IdentTable + stack[i][1]; if (tok == tokIdent && isdigit(*p)) { int label = atoi(p); unsigned len; p = FindString(label); len = *p++; // If this is a string literal initializing an array of char, // truncate or pad it as necessary. if (requiredLen) { if (len >= requiredLen) { len = requiredLen; // copy count requiredLen = 0; // count to be zeroed out } else { requiredLen -= len; // count to be zeroed out } } // Also, calculate its real size for incompletely typed arrays. total = len + requiredLen; if (generatingCode) { if (OutputFormat == FormatFlat) { GenJumpUncond(label + 1); } else { puts2(CodeFooter); puts2(DataHeader); } } GenNumLabel(label); GenStartAsciiString(); printf2("\""); while (len--) { // quote ASCII chars for better readability if (*p >= 0x20 && *p <= 0x7E) { if (*p == '\"' || *p == '\\') printf2("\\"); printf2("%c", *p); } else { printf2("\\%03o", *p & 0xFFu); } p++; } while (requiredLen) { printf2("\\000"); requiredLen--; } printf2("\""); puts2(""); if (generatingCode) { if (OutputFormat == FormatFlat) { GenNumLabel(label + 1); } else { puts2(DataFooter); puts2(CodeHeader); } } } } return total; }