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

📄 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 页
字号:
        case am_pcindxaddr:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "(");
            putconst(ap->offset);
            oprintf(outputFile, ",PC");
            oprintf(outputFile, ",A%d", ap->sreg);
            putsize(ap);
            if (scale != 1)
                oprintf(outputFile, "*%d", scale);
            oputc(')', outputFile);
            break;
        case am_pcindxdata:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "(");
            putconst(ap->offset);
            oprintf(outputFile, ",PC");
            oprintf(outputFile, ",D%d", ap->sreg);
            putsize(ap);
            if (scale != 1)
                oprintf(outputFile, "*%d", scale);
            oputc(')', outputFile);
            break;
        case am_baseindxdata:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "(");
            putconst(ap->offset);
            if (ap->preg !=  - 1)
                oprintf(outputFile, ",A%d", ap->preg);
            oprintf(outputFile, ",D%d", ap->sreg);
            putsize(ap);
            if (scale != 1)
                oprintf(outputFile, "*%d", scale);
            oputc(')', outputFile);
            break;
        case am_baseindxaddr:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "(");
            putconst(ap->offset);
            if (ap->preg !=  - 1)
                oprintf(outputFile, ",A%d", ap->preg);
            oprintf(outputFile, ",A%d", ap->sreg);
            putsize(ap);
            if (scale != 1)
                oprintf(outputFile, "*%d", scale);
            oputc(')', outputFile);
            break;
        case am_iimem:
            oprintf(outputFile, "([");
            putconst(ap->offset);
            oprintf(outputFile, "],");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_iiprea:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "([");
            putconst(ap->offset);
            if (ap->preg !=  - 1)
                oprintf(outputFile, ",A%d", ap->preg);
            if (ap->sreg !=  - 1)
            {
                oprintf(outputFile, ",A%d", ap->sreg);
                putsize(ap);
                if (scale != 1)
                    oprintf(outputFile, "*%d", scale);
            }
            oprintf(outputFile, "],");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_iipred:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "([");
            putconst(ap->offset);
            if (ap->preg !=  - 1)
                oprintf(outputFile, ",A%d", ap->preg);
            if (ap->sreg !=  - 1)
            {
                oprintf(outputFile, ",D%d", ap->sreg);
                putsize(ap);
                if (scale != 1)
                    oprintf(outputFile, "*%d", scale);
            }
            oprintf(outputFile, "],");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_iiposta:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "([");
            putconst(ap->offset);
            if (ap->preg !=  - 1)
                oprintf(outputFile, ",A%d", ap->preg);
            oprintf(outputFile, "]");
            if (ap->sreg !=  - 1)
            {
                oprintf(outputFile, ",A%d", ap->sreg);
                putsize(ap);
                if (scale != 1)
                    oprintf(outputFile, "*%d", scale);
            }
            oprintf(outputFile, ",");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_iipostd:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "([");
            putconst(ap->offset);
            if (ap->preg !=  - 1)
                oprintf(outputFile, ",A%d", ap->preg);
            oprintf(outputFile, "]");
            if (ap->sreg !=  - 1)
            {
                oprintf(outputFile, ",D%d", ap->sreg);
                putsize(ap);
                if (scale != 1)
                    oprintf(outputFile, "*%d", scale);
            }
            oprintf(outputFile, ",");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_iiprepca:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "([");
            putconst(ap->offset);
            oprintf(outputFile, ",PC", ap->preg);
            if (ap->sreg !=  - 1)
            {
                oprintf(outputFile, ",A%d", ap->sreg);
                putsize(ap);
                if (scale != 1)
                    oprintf(outputFile, "*%d", scale);
            }
            oprintf(outputFile, "],");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_iiprepcd:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "([");
            putconst(ap->offset);
            oprintf(outputFile, ",PC", ap->preg);
            if (ap->sreg !=  - 1)
            {
                oprintf(outputFile, ",D%d", ap->sreg);
                putsize(ap);
                if (scale != 1)
                    oprintf(outputFile, "*%d", scale);
            }
            oprintf(outputFile, "],");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_iipostpca:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "([");
            putconst(ap->offset);
            oprintf(outputFile, ",PC]", ap->preg);
            if (ap->sreg !=  - 1)
            {
                oprintf(outputFile, ",A%d", ap->sreg);
                putsize(ap);
                if (scale != 1)
                    oprintf(outputFile, "*%d", scale);
            }
            oprintf(outputFile, ",");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_iipostpcd:
            scale = 1;
            t = ap->scale;
            while (t--)
                scale <<= 1;
            oprintf(outputFile, "([");
            putconst(ap->offset);
            oprintf(outputFile, ",PC]", ap->preg);
            if (ap->sreg !=  - 1)
            {
                oprintf(outputFile, ",D%d", ap->sreg);
                putsize(ap);
                if (scale != 1)
                    oprintf(outputFile, "*%d", scale);
            }
            oprintf(outputFile, ",");
            putconst(ap->offset2);
            oprintf(outputFile, ")");
            break;
        case am_mask:
            put_mask((int)ap->offset);
            break;
        case am_fmask:
            put_fmask((int)ap->offset);
            break;
        default:
            DIAG("illegal address mode.");
            break;
    }
    if (ap->mode &am_bits)
        oprintf(outputFile, " { %d : %d }", ap->bf1, ap->bf2);
}

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

void put_code(OCODE *cd)
/*
 *      outputFile a generic instruction.
 */
{
    int op = cd->opcode, len = cd->length;
    AMODE *aps = cd->oper1,  *apd = cd->oper2,  *ape = cd->oper3;
    if (op == op_void)
        return ;
    nl();
    if (!prm_asmfile)
    {
        ; /* oc_putop(cd); */
        return ;
    }
    if (op == op_line)
    {
        if (!prm_lines)
            return ;
        oprintf(outputFile, ";\n; Line %d:\t%s\n;\n", len, (char*)aps);
        return ;
    }
    if (op == op_slit)
        DIAG("slit in put_code");

    if (op == op_dcl)
    {
        putop(op);
        putlen(len);
        oprintf(outputFile, "\t");
        putamode(aps);
        if (prm_pcrel)
            oprintf(outputFile, "-*");
        oprintf(outputFile, "\n");
        return ;
    }
    else
    {
        putop(op);
        putlen(len);
    }
    if (aps != 0)
    {
        oprintf(outputFile, "\t");
        putamode(aps);
        if (apd != 0)
        {
            if (apd->mode != am_bf && apd->mode != am_bfreg)
                oprintf(outputFile, ",");
            putamode(apd);
            if (ape)
            {
                if (ape->mode != am_bf && ape->mode != am_bfreg)
                    oprintf(outputFile, ",");
                putamode(ape);
            }
        }
    }
    oprintf(outputFile, "\n");
}

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

void put_fmask(int mask)
/*
 *      generate a register mask for floating restore and save.
 */
{
    unsigned put = FALSE, i, bit;
    bit = 1;
    for (i = 0; i < 8; i++)
    {
        if (bit &(unsigned)mask)
        {
            if (put)
                oputc('/', outputFile);
            put = TRUE;
            putreg(i + 16);
        }
        bit <<= 1;
    }
}

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

void put_mask(int mask)
/*
 *      generate a register mask for integer restore and save.
 */
{
    unsigned put = FALSE, i, bit;
    bit = 1;
    for (i = 0; i < 16; i++)
    {
        if (bit &(unsigned)mask)
        {
            if (put)
                oputc('/', outputFile);
            put = TRUE;
            putreg(i);
        }
        bit <<= 1;
    }
}

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

void putreg(int r)
/*
 *      generate a register name from a tempref number.
 */
{
    if (r < 8)
        oprintf(outputFile, "D%d", r);
    else if (r < 16)
        oprintf(outputFile, "A%d", r - 8);
    else
        oprintf(outputFile, "FP%d", r - 16);
}

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

void gen_strlab(SYM *sp)
/*
 *      generate a named label.
 */
{
    char buf[512];
    putsym(buf, sp, sp->name);
    datasp = sp;
    if (prm_asmfile)
    {
        nl();
        oprintf(outputFile, "%s:\n", buf);
    }
    dataofs = 0;
}

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

void put_label(int label)
/*
 *      outputFile a compiler generated label.
 */
{
    if (prm_asmfile)
    {
        nl();
        oprintf(outputFile, "L_%ld:\n", label);
    }
    else
        outcode_put_label(label);
}

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

void put_staticlabel(long label)
{
    if (prm_asmfile)
    {
        nl();
        oprintf(outputFile, "L_%ld:\n", label);
    }
    else
        outcode_put_label(label);
}

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

void genfloat(long double val)
/*
 * Output a float value
 */
{
    if (prm_asmfile)
    if (gentype == floatgen && outcol < 60)
    {
        oprintf(outputFile, ",%.16e", (double)val);
        outcol += 8;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.S\t%.16e", (double)val);
        gentype = floatgen;
        outcol = 19;
    }
    else
        outcode_genfloat(val);
    dataofs += 4;
}

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

void gendouble(long double val)
/*
 * Output a double value
 */
{
    if (prm_asmfile)
    if (gentype == doublegen && outcol < 60)
    {
        oprintf(outputFile, ",%.16e", val);
        outcol += 8;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.D\t%.16e", val);
        gentype = doublegen;
        outcol = 19;
    }
    else
        outcode_gendouble(val);
    dataofs += 8;
}

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

void genlongdouble(long double val)
/*
 * Output a double value
 */
{
    if (prm_asmfile)
    if (gentype == longdoublegen && outcol < 60)
    {
        oprintf(outputFile, ",%.16le", (double)val);
        outcol += 8;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.X\t%.16le", (double)val);
        gentype = longdoublegen;
        outcol = 19;
    }
    else
        outcode_genlongdouble(val);
    dataofs += 10;
}

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

int genstring(char *str, int uselong, int len)
/*
 * Generate a string literal
 */
{
    xstringseg();
    if (prm_asmfile)
    if (uselong)
    {
        len /= 2;
        while (len--)
        {
            genword(*((short*)str));
            str += 2;
        }
        return pstrlen(str) *2;
    }
    else
    {
        while (len--)
            genbyte(*str++);
        return strlen(str);
    }
    else
        outcode_genstring(str, len);
}

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

void genbyte(long val)
/*
 * Output a byte value
 */
{
    if (prm_asmfile)
    if (gentype == bytegen && outcol < 60)
    {
        oprintf(outputFile, ",$%X", val &0x00ff);
        outcol += 4;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.B\t$%X", val &0x00ff);
        gentype = bytegen;
        outcol = 19;
    }
    else
        outcode_genbyte(val);
    dataofs += 1;
}
void genbool(int val)
{
	genbyte(val);
}

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

void genword(long val)
/*
 * Output a word value
 */
{
    if (prm_asmfile)
    if (gentype == wordgen && outcol < 58)
    {
        oprintf(outputFile, ",$%X", val &0x0ffff);
        outcol += 6;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.W\t$%X", val &0x0ffff);
        gentype = wordgen;
        outcol = 21;
    }
    else
        outcode_genword(val);
    dataofs += 2;
}

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

void genlong(long val)
/*
 * Output a long value
 */
{
    if (prm_asmfile)
    if (gentype == longgen && outcol < 56)
    {
        oprintf(outputFile, ",$%lX", val);
        outcol += 10;
    }
    else
    {
        nl();
        oprintf(outputFile, "\tDC.L\t$%lX", val);
        gentype = longgen;
        outcol = 25;
    }
    else
        outcode_genlong(val);
    dataofs += 4;
}
void genint(val)
{
	genlong(val);
}
void genenum(val)
{
	genlong(val);
}

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

void genlonglong(LLONG_TYPE val)
/*
 * Output a long value
 */
{
    if (prm_asmfile)
    if (gentype == longgen && outcol < 56)
    {
        #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 
        outcol += 10;
    }
    else
    {
        nl();

⌨️ 快捷键说明

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