📄 iout.c
字号:
{
oprintf(icdFile, ",$%X", val &0x0ffff);
outcol += 6;
}
else
{
nl();
oprintf(icdFile, "\tDC.W\t$%X", val &0x0ffff);
gentype = wordgen;
outcol = 21;
}
dataofs += 2;
}
//-------------------------------------------------------------------------
void genlong(long val)
/*
* Output a long value
*/
{
if (gentype == longgen && outcol < 56)
{
oprintf(icdFile, ",$%lX", val);
outcol += 10;
}
else
{
nl();
oprintf(icdFile, "\tDC.L\t$%lX", val);
gentype = longgen;
outcol = 25;
}
dataofs += 4;
}
//-------------------------------------------------------------------------
void genlonglong(LLONG_TYPE val)
/*
* Output a long value
*/
{
if (gentype == longgen && outcol < 56)
{
#ifdef BCC32
oprintf(icdFile, "\tDC.L\t0%lXH,0%lXH", val, val < 0 ? - 1: 0);
#else
oprintf(icdFile, "\tDC.L\t0%lXH,0%lXH", val, val >> 32);
#endif
outcol += 10;
}
else
{
nl();
#ifdef BCC32
oprintf(icdFile, "\tDC.L\t0%lXH,0%lXH", val, val < 0 ? - 1: 0);
#else
oprintf(icdFile, "\tDC.L\t0%lXH,0%lXH", val, val >> 32);
#endif
gentype = longgen;
outcol = 25;
}
}
void genint(int val)
{
if (gentype == intgen && outcol < 56)
{
oprintf(icdFile, ",$%lX", val);
outcol += 10;
}
else
{
nl();
oprintf(icdFile, "\tDC.I\t$%lX", val);
gentype = intgen;
outcol = 25;
}
dataofs += 4;
}
void genenum(int val)
{
if (gentype == enumgen && outcol < 56)
{
oprintf(icdFile, ",$%lX", val);
outcol += 10;
}
else
{
nl();
oprintf(icdFile, "\tDC.ENUM\t$%lX", val);
gentype = enumgen;
outcol = 25;
}
dataofs += 4;
}
//-------------------------------------------------------------------------
void genaddress(char *string)
/*
* Output a long value
*/
{
if (gentype == longgen && outcol < 56)
{
oprintf(icdFile, ",%s", string);
outcol += strlen(string);
}
else
{
nl();
oprintf(icdFile, "\tDC.A\t%s", string);
gentype = longgen;
outcol = 25;
}
dataofs += 4;
}
//-------------------------------------------------------------------------
void gensrref(char *name, int val)
/*
* Output a startup/rundown reference
*/
{
if (gentype == srrefgen && outcol < 56)
{
oprintf(icdFile, ",%s,%d", name, val);
outcol += strlen(name) + 1;
}
else
{
nl();
oprintf(icdFile, "\tDC.A\t%s,%d", name, val);
gentype = srrefgen;
outcol = 25;
}
}
//-------------------------------------------------------------------------
void genref(SYM *sp, int offset)
/*
* Output a reference to the data area (also gens fixups )
*/
{
char sign;
char buf[40];
if (offset < 0)
{
sign = '-';
offset = - offset;
}
else
sign = '+';
sprintf(buf, "%s%c%d", sp->name, sign, offset);
{
if (gentype == longgen && outcol < 55-strlen(sp->name))
{
oprintf(icdFile, ",%s", buf);
outcol += (11+strlen(sp->name));
}
else
{
nl();
oprintf(icdFile, "\tDC.A\t%s", buf);
outcol = 26+strlen(sp->name);
gentype = longgen;
}
}
dataofs += 4;
}
//-------------------------------------------------------------------------
void genpcref(SYM *sp, int offset)
/*
* Output a reference to the code area (also gens fixups )
*/
{
char sign;
char buf[40];
if (offset < 0)
{
sign = '-';
offset = - offset;
}
else
sign = '+';
sprintf(buf, "%s%c%d", sp->name, sign, offset);
{
if (gentype == longgen && outcol < 55-strlen(sp->name))
{
oprintf(icdFile, ",%s", buf);
outcol += (11+strlen(sp->name));
}
else
{
nl();
oprintf(icdFile, "\tDC.A\t%s", buf);
outcol = 26+strlen(sp->name);
gentype = longgen;
}
}
dataofs += 4;
}
//-------------------------------------------------------------------------
void genstorage(int nbytes)
/*
* Output bytes of storage
*/
{
{
nl();
oprintf(icdFile, "\tDS.B\t$%X\n", nbytes);
}
dataofs += nbytes;
}
//-------------------------------------------------------------------------
void gen_labref(int n)
/*
* Generate a reference to a label
*/
{
if (gentype == longgen && outcol < 58)
{
oprintf(icdFile, ",L_%d", n);
outcol += 6;
}
else
{
nl();
oprintf(icdFile, "\tDC.A\tL_%d", n);
outcol = 22;
gentype = longgen;
}
dataofs += 4;
}
void gen_labdifref(int n1, int n2)
{
{
if (gentype == longgen && outcol < 58)
{
oprintf(icdFile, ",L_%d-L_%d", n1, n2);
outcol += 6;
}
else
{
if (!newlabel)
nl();
else
newlabel = FALSE;
oprintf(icdFile, "\tDC.A\tL_%d-L_%d", n1, n2);
outcol = 22;
gentype = longgen;
}
}
}
//-------------------------------------------------------------------------
int stringlit(char *s, int uselong, int len)
/*
* make s a string literal and return it's label number.
*/
{
struct slit *lp = strtab;
if (uselong)
len *= 2;
if (prm_optmult)
{
while (lp)
{
if (len == lp->len && !memcmp(lp->str, s, len))
return lp->label;
lp = lp->next;
}
}
++global_flag; /* always allocate from global space. */
lp = xalloc(sizeof(struct slit));
lp->label = nextlabel++;
lp->str = xalloc(len);
memcpy(lp->str, s, len);
lp->len = len;
lp->next = strtab;
lp->type = uselong;
strtab = lp;
--global_flag;
return lp->label;
}
//-------------------------------------------------------------------------
void dumplits(void)
/*
* dump the string literal pool.
*/
{
{
while (strtab != 0)
{
xstringseg();
nl();
put_label(strtab->label);
genstring(strtab->str, strtab->type, strtab->len - 1);
if (strtab->type)
genword(0);
else
genbyte(0);
strtab = strtab->next;
} nl();
}
}
//-------------------------------------------------------------------------
void nl(void)
/*
* New line
*/
{
{
if (outcol > 0)
{
oputc('\n', icdFile);
outcol = 0;
gentype = nogen;
}
}
}
/*
* Switch to cseg
*/
void cseg(void)
{
if (curseg != codeseg)
{
nl();
oprintf(icdFile, "\tSECTION\tcode\n");
curseg = codeseg;
}
}
/*
* Switch to dseg
*/
void dseg(void)
{
if (curseg != dataseg)
{
nl();
oprintf(icdFile, "\tSECTION\tdata\n");
curseg = dataseg;
}
}
/*
* Switch to bssseg
*/
void bssseg(void)
{
if (curseg != bssxseg)
{
nl();
oprintf(icdFile, "\tSECTION\tbss\n");
curseg = bssxseg;
}
}
/*
* Switch to const seg
*/
void xconstseg(void)
{
if (curseg != constseg)
{
nl();
oprintf(icdFile, "\tSECTION\tconst\n");
curseg = constseg;
}
}
/*
* Switch to string seg
*/
void xstringseg(void)
{
if (curseg != stringseg)
{
nl();
oprintf(icdFile, "\tSECTION\tstring\n");
curseg = stringseg;
}
}
/*
* Switch to startupseg
*/
void startupseg(void)
{
if (curseg != startupxseg)
{
nl();
oprintf(icdFile, "\tSECTION\tcstartup\n");
curseg = startupxseg;
}
}
/*
* Switch to rundownseg
*/
void rundownseg(void)
{
if (curseg != rundownxseg)
{
nl();
oprintf(icdFile, "\tSECTION\tcrundown\n");
curseg = rundownxseg;
}
}
/*
* Switch to cppseg
*/
void cppseg(void)
{
if (curseg != cppxseg)
{
nl();
oprintf(icdFile, "\tSECTION\tcppinit\n");
curseg = cppxseg;
}
}
//-------------------------------------------------------------------------
void cpprdseg(void)
{
if (curseg != xcpprdseg)
{
nl();
oprintf(icdFile, "\tSECTION\tcpprundown\n");
curseg = xcpprdseg;
}
}
//-------------------------------------------------------------------------
void exitseg(void)
{
}
void gen_virtual(SYM *sp, int data)
{
{
char buf[512];
if (!data && curseg != codeseg)
cseg();
virtual_mode = data;
curseg = virtseg;
putsym(buf, sp, sp->name);
nl();
oprintf(icdFile, "@%s\tVIRTUAL", buf);
oprintf(icdFile, "%s:\n", buf);
}
}
//-------------------------------------------------------------------------
void gen_endvirtual(SYM *sp)
{
{
char buf[512];
putsym(buf, sp, sp->name);
nl();
oprintf(icdFile, "@%s\tENDVIRTUAL", buf);
if (virtual_mode)
dseg();
else
cseg();
}
}
void align(int size)
{
if (curseg == codeseg)
return ;
nl();
oprintf("align %d\n",size);
}
//-------------------------------------------------------------------------
void asm_header(void)
{
oprintf(icdFile, ";Icode test - %s\n\n", outfile);
}
//-------------------------------------------------------------------------
void globaldef(SYM *sp)
{
char buf[100], *q = buf, *p = sp->name;
if (curseg == codeseg && currentfunc->pascaldefn)
{
if (prm_cmangle)
p++;
while (*p)
*q++ = toupper(*p++);
*q++ = 0;
}
else
strcpy(buf, p);
oprintf(icdFile, "\tPUBLIC\t%s\n", buf);
}
//-------------------------------------------------------------------------
void output_alias(SYM *sp)
{
char buf[256];
putsym(buf, sp, sp->name);
oprintf(icdFile, "%s EQU\t<%s>\n", buf, sp->alias);
}
//-------------------------------------------------------------------------
int put_exfunc(SYM *sp, int notyet)
{
char buf[100], *q = buf, *p = sp->name;
putsym(buf, sp, p);
if (notyet)
{
oprintf(icdFile, "\n\t.CODE\n");
notyet = FALSE;
}
if (sp->tp->type == bt_func || sp->tp->type == bt_ifunc)
oprintf(icdFile, "\tEXTRN\t%s:PROC\n", buf);
else
oprintf(icdFile, "\tEXTRN\t%s:DATA\n", buf);
if (sp->importable)
oprintf(icdFile, "\timport %s %s\n", buf, sp->importfile);
return notyet;
}
//-------------------------------------------------------------------------
int put_expfunc(SYM *sp, int notyet)
{
char buf[256];
if (notyet)
{
oprintf(icdFile, "\n.CODE\n");
notyet = FALSE;
}
putsym(buf, sp, sp->name);
oprintf(icdFile, "\texport %s\n", buf);
}
//-------------------------------------------------------------------------
void putexterns(void)
/*
* Output the fixup tables and the global/external list
*/
{
SYM *sp;
int i;
LIST *l;
char buf[100];
{
int notyet = TRUE;
nl();
exitseg();
for (i = 0; i < HASHTABLESIZE; i++)
{
if ((sp = (SYM*)gsyms[i]) != 0)
{
while (sp)
{
if (sp->storage_class == sc_externalfunc && sp->mainsym
->extflag && !(sp->tp->cflags &DF_INTRINS))
notyet = put_exfunc(sp, notyet);
if (sp->storage_class == sc_external && sp->mainsym
->extflag)
notyet = put_exfunc(sp, notyet);
if (sp->storage_class == sc_defunc)
{
SYM *sp1 = sp->tp->lst.head;
while (sp1)
{
if (sp1->storage_class == sc_externalfunc && sp1
->mainsym->extflag && !(sp1->tp->cflags
&DF_INTRINS))
{
notyet = put_exfunc(sp1, notyet);
}
sp1 = sp1->next;
}
}
if (sp->exportable)
notyet = put_expfunc(sp, notyet);
sp = sp->next;
}
}
}
while (localfuncs)
{
sp = localfuncs->data;
if (sp->storage_class == sc_externalfunc && sp->mainsym->extflag &&
!(sp->tp->cflags &DF_INTRINS))
notyet = put_exfunc(sp, notyet);
if (sp->exportable)
notyet = put_expfunc(sp, notyet);
localfuncs = localfuncs->link;
}
notyet = TRUE;
if (libincludes)
{
while (libincludes)
{
oprintf(icdFile, "\tINCLUDELIB\t%s\n", libincludes->data);
libincludes = libincludes->link;
}
oputc('\n', icdFile);
}
oprintf(icdFile, "\tEND\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -