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

📄 inasm68.c

📁 CC386 is a general-purpose 32-bit C compiler. It is not an optimizing compiler but given that the co
💻 C
📖 第 1 页 / 共 5 页
字号:
    return make_ocode(ap2, ap1, 0);
}

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

static OCODE *ope_eai(void)
{
    fatal("unimplemented");
}

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

static OCODE *ope_rrl(void)
{
    AMODE *ap1,  *ap2;
    if (!needsize(4))
        return 0;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if ((ap1->mode != am_areg && ap1->mode != am_dreg) || (ap2->mode != am_areg
        && ap2->mode != am_dreg))
    {
        asm_err(ERR_AILLADDRESS);
        return 0;
    }
    return make_ocode(ap1, ap2, 0);
}

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

static OCODE *ope_ext(void)
{
    AMODE *ap1;
    if (!wordsize())
        return 0;
    if (!theSize)
        theSize = 2;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    if (!dreg(ap1))
        return 0;
    return make_ocode(ap1, 0, 0);
}

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

static OCODE *ope_extb(void)
{
    AMODE *ap1;
    if (!needsize(4))
        return 0;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    if (!dreg(ap1))
        return 0;
    return make_ocode(ap1, 0, 0);
}

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

static OCODE *ope_ai(void)
{
    AMODE *ap1,  *ap2;
    if (!prm_68020)
    {
        if (!needsize(2))
            return 0;
    }
    else
        if (!wordsize())
            return 0;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    if (ap1->mode != am_areg)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (ap2->mode != am_immed)
        return (OCODE*) - 1;
    return make_ocode(ap1, ap2, 0);
}

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

static OCODE *ope_move(void)
{
    AMODE *ap1,  *ap2;
    if (!intsize())
        return 0;
    if (!theSize)
        theSize = 2;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (ap1->mode == am_usp)
    {
        if (!needsize(4))
            return 0;
        if (ap2->mode != am_areg)
        {
            return (OCODE*) - 1;
        }
    }
    else
    if (ap2->mode == am_usp)
    {
        if (!needsize(4))
            return 0;
        if (ap1->mode != am_areg)
        {
            return (OCODE*) - 1;
        }
    }
    else
    if (ap1->mode == am_sr || ap1->mode == am_ccr)
    {
        if (!needsize(ap1->mode == am_sr ? 2 : 1))
            return 0;
        if (!vermode(ap2, TRUE, FALSE, FALSE, FALSE))
            return 0;
    }
    else
    if (ap2->mode == am_sr || ap2->mode == am_ccr)
    {
        if (!needsize(ap2->mode == am_sr ? 2 : 1))
            return 0;
        if (!vermode(ap1, TRUE, FALSE, TRUE, TRUE))
            return 0;
    }
    else
    {
        if (ap1->mode == am_areg || ap2->mode == am_areg)
        {
            if (!wordsize())
                return 0;
        }
        else
            if (!intsize())
                return 0;
        if (!vermode(ap1, TRUE, TRUE, TRUE, TRUE))
            return 0;
        if (!vermode(ap2, TRUE, TRUE, FALSE, FALSE))
            return 0;
    }
    return make_ocode(ap1, ap2, 0);
}

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

static OCODE *ope_movea(void)
{
    AMODE *ap1,  *ap2;
    if (!wordsize())
        return 0;
    if (!theSize)
        theSize = 2;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (ap2->mode != am_areg)
    {
        return (OCODE*) - 1;
    }
    if (!vermode(ap1, TRUE, TRUE, TRUE, TRUE))
        return 0;
    return make_ocode(ap1, ap2, 0);
}

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

static OCODE *ope_movec(void)
{
    AMODE *ap1,  *ap2,  *ap3;
    if (!needsize(4))
        return 0;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (ap1->mode == am_areg || ap1->mode == am_dreg)
        ap3 = ap2;
    else if (ap2->mode == am_areg || ap2->mode == am_dreg)
        ap3 = ap1;
    else
    {
        return (OCODE*) - 1;
    }
    switch (ap3->mode)
    {
        case am_sfc:
        case am_dfc:
        case am_usp:
        case am_vbr:
            if (prm_68010)
                break;
        case am_cacr:
        case am_caar:
        case am_msp:
        case am_isp:
            if (prm_68020)
                break;
        default:
            return (OCODE*) - 1;
    }
    return make_ocode(ap1, ap2, 0);


}

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

static OCODE *ope_movem(void)
{
    AMODE *ap1,  *ap2;
    if (!wordsize())
        return 0;
    ap1 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (ap1->mode == am_dreg || ap1->mode == am_areg || ap1->mode == am_mask)
    {
        if (ap1->mode == am_dreg)
        {
            ap1->offset = (void*)(1 << ap1->preg);
            ap1->mode = am_mask;
        }
        else if (ap1->mode == am_areg)
        {
            ap1->offset = (void*)(0x100 << ap1->preg);
            ap1->mode = am_mask;
        }
        if (!vermode(ap2, FALSE, FALSE, FALSE, FALSE))
            return 0;
        if (ap2->mode == am_ainc)
        {
            return (OCODE*) - 1;
        }

    }
    else
    if (ap2->mode == am_dreg || ap2->mode == am_areg || ap2->mode == am_mask)
    {
        if (ap2->mode == am_dreg)
        {
            ap2->offset = (void*)(1 << ap2->preg);
            ap2->mode = am_mask;
        }
        else if (ap2->mode == am_areg)
        {
            ap2->offset = (void*)(0x100 << ap2->preg);
            ap2->mode = am_mask;
        }
        if (!vermode(ap1, FALSE, FALSE, FALSE, FALSE))
            return 0;
        if (ap1->mode == am_adec)
        {
            return (OCODE*) - 1;
        }
    }
    else
        return 0;
    return make_ocode(ap1, ap2, 0);
}

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

static OCODE *ope_movep(void)
{
    AMODE *ap1,  *ap2;
    if (!wordsize())
        return 0;
    if (!theSize)
        theSize = 2;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (ap1->mode == am_dreg && ap2->mode == am_indx || ap2->mode == am_dreg &&
        ap1->mode == am_indx)
    {
        return make_ocode(ap1, ap2, 0);

    }
    else
    {
        return (OCODE*) - 1;
    }
}

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

static OCODE *ope_moveq(void)
{
    AMODE *ap1,  *ap2;
    if (!intsize())
        return 0;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (ap1->mode == am_immed && ap2->mode == am_dreg)
        if (ap1->offset->v.i >=  - 128 && ap1->offset->v.i <= 127)
            return make_ocode(ap1, ap2, 0);
        else
    {
        asm_err(ERR_CONSTTOOLARGE);
        return 0;
    }
    else
        return (OCODE*) - 1;
    return (OCODE*) - 1;


}

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

static OCODE *ope_moves(void)
{
    AMODE *ap1,  *ap2;
    if (!need_010())
        return 0;
    if (!intsize())
        return 0;
    if (!theSize)
        theSize = 2;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (ap1->mode == am_dreg)
    {
        if (!vermode(ap2, FALSE, FALSE, FALSE, FALSE))
            return 0;
    }
    else
    if (ap2->mode == am_dreg)
    {
        if (!vermode(ap1, FALSE, FALSE, FALSE, FALSE))
            return 0;
    }
    else
        return (OCODE*) - 1;

    return make_ocode(ap1, ap2, 0);
}

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

static OCODE *ope_mul(void)
{
    AMODE *ap1,  *ap2;
    if (!wordsize())
        return 0;
    if (theSize == 4 && !need_020())
        return 0;
    if (!theSize)
        theSize = 2;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    if (!vermode(ap1, TRUE, FALSE, TRUE, TRUE))
        return 0;
    if (ap2->mode != am_dreg && (ap2->mode != am_divsl || theSize != 4))
    {
        return (OCODE*) - 1;
    }
    return make_ocode(ap1, ap2, 0);
}

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

static OCODE *ope_eab(void)
{
    AMODE *ap1;
    if (theSize > 1)
    {
        return (OCODE*) - 2;
    }
    if (theSize == 4 && !need_020())
        return 0;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    if (!vermode(ap1, TRUE, FALSE, FALSE, FALSE))
        return 0;
    return make_ocode(ap1, 0, 0);
}

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

static OCODE *ope_pack(void)
{
    AMODE *ap1,  *ap2,  *ap3;
    if (theSize)
    {
        return (OCODE*) - 2;
    }
    if (!need_020())
        return 0;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap2 = asm_amode();
    if (!ap2)
        return (OCODE*) - 1;
    needpunc(comma, 0);
    ap3 = asm_amode();
    if (!ap3)
        return (OCODE*) - 1;
    if (ap1->mode != ap2->mode || (ap1->mode != am_dreg && ap1->mode != am_adec)
        || (ap3->mode != am_immed) || (ap3->offset->v.i &0xffff0000))
    {
        return (OCODE*) - 1;
    }
    return make_ocode(ap1, ap2, ap3);
}

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

static OCODE *ope_i(void)
{
    AMODE *ap1;
    if (theSize)
    {
        return (OCODE*) - 2;
    }
    //   if (!need_010())
    //      return 0;
    ap1 = asm_amode();
    if (!ap1)
        return (OCODE*) - 1;
    if (ap1->mode != am_immed || (ap1->offset->v.i &0xffff0000))
    {
        asm_err(ERR_CONSTTOOLARGE);
        return 0;
    }
    return make_ocode(ap1, 0, 0);


}

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

static OCODE *ope_set(void)
{
    return (ope_eab());
}

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

static OCODE *ope_d(void)
{
    AMODE *ap1;
    if (!need_dreg(&ap1))
        return 0;
    if (theSize)
    {
        return (OCODE*) - 2;
    }
    return make_ocode(ap1, 0, 0);
}

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

static OCODE *ope_trapcc(void)
{
    AMODE *ap1 = 0;
    if (!need_020())
        return 0;
    if (!wordsize())
        return 0;
    if (!theSize)
        theSize = 2;
    if (lastst != hash)
        return make_ocode(0, 0, 0);
    ap1 = asm_amode();
    if (!ap1)
    {
        return (OCODE*) - 1;
    }
    if (ap1->mode != am_immed)
    {
        return (OCODE*) - 1;
    }
    if (theSize == 2 && (ap1->offset->v.i &0xffff0000))
    {
        asm_err(ERR_CONSTTOOLARGE);
        return 0;
    }
    return make_ocode(ap1, 0, 0);
}

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

⌨️ 快捷键说明

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