⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outas68.c

📁 CC386 is a general-purpose 32-bit C compiler. It is not an optimizing compiler but given that the co
💻 C
📖 第 1 页 / 共 5 页
字号:
        #if sizeof(ULLONG_TYPE) == 4
            oprintf(outputFile, "\tDC.L\t0,$%lX, $%lX", val < 0 ?  - 1: 0, val);
        #else 
            oprintf(outputFile, "\tDC.L\t0,$%lX, $%lX", val >> 32, val);
        #endif 
        gentype = longgen;
        outcol = 25;
    }
    else
        outcode_genlonglong(val);
    dataofs += 8;
}

/*
 * Generate a startup or rundown reference
 */
void gensrref(SYM *sp, int val)
{
    char buf[512];
    putsym(buf, sp, sp->name);
    if (prm_asmfile)
    {
        if (gentype == srrefgen && outcol < 56)
        {
            oprintf(outputFile, ",%s,%d", buf, val);
            outcol += strlen(sp->name) + 1;
        }
        else
        {
            nl();
            oprintf(outputFile, "\tDC.L\t%s,%d", buf, val);
            gentype = srrefgen;
            outcol = 25;
        }
    }
    else
        outcode_gensrref(sp, val);
}

//-------------------------------------------------------------------------

void genref(SYM *sp, int offset)
/*
 * Output a reference to the data area (also gens fixups )
 */
{
    char sign;
    char buf[512], name[512];
    putsym(name, sp, sp->name);
    if (offset < 0)
    {
        sign = '-';
        offset =  - offset;
    }
    else
        sign = '+';
    sprintf(buf, "%s%c%d", name, sign, offset);
    datalink(FALSE);
    if (prm_asmfile)
    {
        if (gentype == longgen && outcol < 55-strlen(name))
        {
            oprintf(outputFile, ",%s", buf);
            outcol += (11+strlen(name));
        }
        else
        {
            nl();
            oprintf(outputFile, "\tDC.L\t%s", buf);
            outcol = 26+strlen(name);
            gentype = longgen;
        }
    }
    else
        outcode_genref(sp, offset);
    dataofs += 4;
}

//-------------------------------------------------------------------------

void genpcref(SYM *sp, int offset)
/*
 * Output a reference to the code area (also gens fixups )
 */
{
    char sign;
    char buf[512], name[512];
    putsym(name, sp, sp->name);
    if (offset < 0)
    {
        sign = '-';
        offset =  - offset;
    }
    else
        sign = '+';
    sprintf(buf, "%s%c%d", name, sign, offset);
    datalink(TRUE);
    if (prm_asmfile)
    {
        if (gentype == longgen && outcol < 55-strlen(name))
        {
            oprintf(outputFile, ",%s", buf);
            outcol += (11+strlen(name));
        }
        else
        {
            nl();
            oprintf(outputFile, "\tDC.L\t%s", buf);
            outcol = 26+strlen(name);
            gentype = longgen;
        }
    }
    else
        outcode_genref(sp, offset);
    dataofs += 4;
}

//-------------------------------------------------------------------------

void genstorage(int nbytes)
/*
 * Output bytes of storage
 */
{
    if (prm_asmfile)
    {
        nl();
        oprintf(outputFile, "\tDS.B\t$%X\n", nbytes);
    }
    else
        outcode_genstorage(nbytes);
    dataofs += nbytes;
}

//-------------------------------------------------------------------------

void gen_labref(int n)
/*
 * Generate a reference to a label
 */
{
    if (prm_asmfile)
    if (gentype == longgen && outcol < 58)
    {
        oprintf(outputFile, ",L_%d", n);
        outcol += 6;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.L\tL_%d", n);
        outcol = 22;
        gentype = longgen;
    }
    else
        outcode_gen_labref(n);
    datalink(TRUE);
    dataofs += 4;
}

//-------------------------------------------------------------------------

void gen_labdifref(int n1, int n2)
/*
 * Generate a reference to a label
 */
{
    if (prm_asmfile)
    if (gentype == longgen && outcol < 58)
    {
        oprintf(outputFile, ",L_%d-L_%d", n1, n2);
        outcol += 6;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.L\tL_%d-L_%d", n1, n2);
        outcol = 22;
        gentype = longgen;
    }
    else
        outcode_gen_labdifref(n1, n2);
    datalink(TRUE);
    dataofs += 4;
}

//-------------------------------------------------------------------------

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)
{
    if (prm_asmfile)
    {
        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();
    }
    else
        outcode_dumplits();
}

/*
 * Switch to cseg 
 */
void cseg(void)
{
    if (prm_asmfile)
    if (curseg != codeseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tcode\n");
    }
    curseg = codeseg;

}

//-------------------------------------------------------------------------

void xconstseg(void)
{
    if (prm_asmfile)
    if (curseg != constseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tconst\n");
    }
    curseg = constseg;
}

//-------------------------------------------------------------------------

void xstringseg(void)
{
    if (prm_asmfile)
    if (curseg != stringseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tstring\n");
    }
    curseg = stringseg;
}

/*
 * Switch to dseg
 */
void dseg(void)
{
    if (prm_asmfile)
    if (curseg != dataseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tdata\n");
    }
    curseg = dataseg;
}

/*
 * Switch to bssseg
 */
void bssseg(void)
{
    if (prm_asmfile)
    if (curseg != bssxseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tbss\n");
    }
    curseg = bssxseg;
}

/*
 * Switch to startupseg
 */
void startupseg(void)
{
    if (prm_asmfile)
    if (curseg != startupxseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tcstartup\n");
    }
    curseg = startupxseg;
}

/*
 * Switch to rundownseg
 */
void rundownseg(void)
{
    if (prm_asmfile)
    if (curseg != rundownxseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tcrundown\n");
    }
    curseg = rundownxseg;
}

/*
 * Switch to cppseg
 */
void cppseg(void)
{
    if (prm_asmfile)
    if (curseg != cppxseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tcppinit\n");
    }
    curseg = cppxseg;
}

//-------------------------------------------------------------------------

void cpprdseg(void)
{
    if (prm_asmfile)
    if (curseg != cpprseg)
    {
        nl();
        oprintf(outputFile, "\tSECTION\tcppexit\n");
    }
    curseg = cpprseg;
}

//-------------------------------------------------------------------------

void gen_virtual(SYM *sp, int data)
/*
 * Generate a virtual segment
 */
{
    char buf[512];
    if (!data && curseg != codeseg)
        cseg();
    curseg = virtseg;
    if (prm_asmfile)
    {
        nl();
        putsym(buf, sp, sp->name);
        oprintf(outputFile, "\tVIRTUAL\t @%s\n", buf);
        oprintf(outputFile, "%s:\n", buf);
    }
    else
        outcode_start_virtual_seg(sp, data);
}

//-------------------------------------------------------------------------

void gen_endvirtual(SYM *sp)
/*
 * Generate the end of a virtual segment
 */
{
    if (prm_asmfile)
    {
        //      nl();
        //      oprintf(outputFile,"\tENDVIRTUAL @%s\n",sp->name);
    }
    else
        outcode_end_virtual_seg(sp);
    curseg = noseg;
}

//-------------------------------------------------------------------------

void genlongref(DATALINK *p)
/*
 * Generate a reference reference for fixup tables
 */
{
    if (prm_asmfile)
    if (gentype == longgen && outcol < 56)
    {
        oprintf(outputFile, ",%s+$%X", p->sp->name, p->offset);
        outcol += 10;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.L\t%s+$%X", p->sp->name, p->offset);
        gentype = longgen;
        outcol = 25;
    }
    else
        outcode_genref(p->sp, p->offset);
}

/*
 * Assembly file header
 */
void asm_header(void){}
void globaldef(SYM *sp)
/*
 * Stick in a global definition
 */
{
    char name[512];
    putsym(name, sp, sp->name);
    if (prm_asmfile)
    {
        nl();
        oprintf(outputFile, "\tXDEF\t%s\n", name);
    }
}

//-------------------------------------------------------------------------

void output_alias(char *name, char *alias)
{
    oprintf(outputFile, "%s EQU\t<%s>\n", name, alias);
}

//-------------------------------------------------------------------------

static void dumphashtable(HASHREC **syms)
{
    SYM *sp;
    int i;
    char buf[512];
    for (i = 0; i < HASHTABLESIZE; i++)
    {
        if ((sp = (SYM*)syms[i]) != 0)
        {
            while (sp)
            {
                if (sp->storage_class == sc_externalfunc && sp->mainsym
                    ->extflag && !(sp->tp->cflags &DF_INTRINS))
                {
                    putsym(buf, sp, sp->name);
                    oprintf(outputFile, "\tXREF\t%s\n", buf);
                }
                if (sp->storage_class == sc_external && sp->mainsym->extflag)
                {
                    putsym(buf, sp, sp->name);
                    oprintf(outputFile, "\tXREF\t%s\n", buf);
                }
                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)
                            )
                        {
                            putsym(buf, sp1, sp1->name);
                            oprintf(outputFile, "\tXREF\t%s\n", buf);
                        }
                        sp1 = sp1->next;
                    }
                }
                if (sp->storage_class == sc_namespace && !sp
                    ->value.classdata.parentns->anonymous)
                    dumphashtable(sp->value.classdata.parentns->table);
                sp = sp->next;
            }
        }
    }
}

//-------------------------------------------------------------------------

void putexterns(void)
/*
 * Output the fixup tables and the global/external list
 */
{
    SYM *sp;
    DATALINK *p;
    int i, notyetg;
    int started = FALSE;
    p = datahead;
    curseg = fixcseg;
    if (!prm_asmfile)
        return ;
    #ifndef COLDFIRE
        while (p)
        {
            if (p->type)
            {
                if (!started && prm_asmfile)
                {
                    nl();
                    oprintf(outputFile, "\tSECTION\tcodefix\n");
                    started = TRUE;
                }
                genlongref(p);
            }
            p = p->next;
        }
        started = FALSE;
        p = datahead;
        curseg = fixdseg;
        while (p)
        {
            if (!p->type)
            {
                if (!started && prm_asmfile)
                {
                    nl();
                    oprintf(outputFile, "\tSECTION\tdatafix\n");
                    started = TRUE;
                }
                genlongref(p);
            }
            p = p->next;
        }
    #endif 
    curseg = noseg;
    if (prm_asmfile)
    {
        nl();
        dumphashtable(gsyms);
    }
    while (localfuncs)
    {
        sp = localfuncs->data;
        if (sp->storage_class == sc_externalfunc && sp->mainsym->extflag && !
            (sp->tp->cflags &DF_INTRINS))
        {
            if (!sp->mainsym->gennedvirtfunc)
            {
                char buf[512];
                putsym(buf, sp, sp->name);
                oprintf(outputFile, "\tXREF\t%s\n", buf);
            }
        }
        localfuncs = localfuncs->link;
    }
    for (i = 0; i < HASHTABLESIZE; i++)
    {
        struct _templatelist *tl;
        if ((tl = (struct templatelist*)templateFuncs[i]) != 0)
        {
            while (tl)
            {
                if (!tl->sp->value.classdata.templatedata->hasbody)
                {
                    if (tl->finalsp && !tl->finalsp->gennedvirtfunc)
                    {
                        char buf[512];
                        putsym(buf, tl->finalsp, sp->name);
                        oprintf(outputFile, "\tXREF\t%s\n", buf);
                    } 
                }
                tl = tl->next;
            }
        }
    }
    while (localdata)
    {
        sp = localdata->data;
        if (sp->mainsym->extflag)
        {
            char buf[512];
            putsym(buf, sp, sp->name);
            oprintf(outputFile, "\tXREF\t%s\n", buf);
        }
        localdata = localdata->link;
    }
    if (libincludes)
    {
        while (libincludes)
        {
            oprintf(outputFile, "\tINCLUDELIB\t%s\n", libincludes->data);
            libincludes = libincludes->link;
        }
        oputc('\n', outputFile);
    }
    oprintf(outputFile, "\tEND\n");


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -