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

📄 op.c

📁 QEMU 0.91 source code, supports ARM processor including S3C24xx series
💻 C
📖 第 1 页 / 共 5 页
字号:
/* *  MIPS emulation micro-operations for qemu. * *  Copyright (c) 2004-2005 Jocelyn Mayer *  Copyright (c) 2006 Marius Groeger (FPU operations) *  Copyright (c) 2007 Thiemo Seufer (64-bit FPU support) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include "config.h"#include "exec.h"#include "host-utils.h"#ifndef CALL_FROM_TB0#define CALL_FROM_TB0(func) func()#endif#ifndef CALL_FROM_TB1#define CALL_FROM_TB1(func, arg0) func(arg0)#endif#ifndef CALL_FROM_TB1_CONST16#define CALL_FROM_TB1_CONST16(func, arg0) CALL_FROM_TB1(func, arg0)#endif#ifndef CALL_FROM_TB2#define CALL_FROM_TB2(func, arg0, arg1) func(arg0, arg1)#endif#ifndef CALL_FROM_TB2_CONST16#define CALL_FROM_TB2_CONST16(func, arg0, arg1)     \        CALL_FROM_TB2(func, arg0, arg1)#endif#ifndef CALL_FROM_TB3#define CALL_FROM_TB3(func, arg0, arg1, arg2) func(arg0, arg1, arg2)#endif#ifndef CALL_FROM_TB4#define CALL_FROM_TB4(func, arg0, arg1, arg2, arg3) \        func(arg0, arg1, arg2, arg3)#endif#define REG 1#include "op_template.c"#undef REG#define REG 2#include "op_template.c"#undef REG#define REG 3#include "op_template.c"#undef REG#define REG 4#include "op_template.c"#undef REG#define REG 5#include "op_template.c"#undef REG#define REG 6#include "op_template.c"#undef REG#define REG 7#include "op_template.c"#undef REG#define REG 8#include "op_template.c"#undef REG#define REG 9#include "op_template.c"#undef REG#define REG 10#include "op_template.c"#undef REG#define REG 11#include "op_template.c"#undef REG#define REG 12#include "op_template.c"#undef REG#define REG 13#include "op_template.c"#undef REG#define REG 14#include "op_template.c"#undef REG#define REG 15#include "op_template.c"#undef REG#define REG 16#include "op_template.c"#undef REG#define REG 17#include "op_template.c"#undef REG#define REG 18#include "op_template.c"#undef REG#define REG 19#include "op_template.c"#undef REG#define REG 20#include "op_template.c"#undef REG#define REG 21#include "op_template.c"#undef REG#define REG 22#include "op_template.c"#undef REG#define REG 23#include "op_template.c"#undef REG#define REG 24#include "op_template.c"#undef REG#define REG 25#include "op_template.c"#undef REG#define REG 26#include "op_template.c"#undef REG#define REG 27#include "op_template.c"#undef REG#define REG 28#include "op_template.c"#undef REG#define REG 29#include "op_template.c"#undef REG#define REG 30#include "op_template.c"#undef REG#define REG 31#include "op_template.c"#undef REG#define TN#include "op_template.c"#undef TN#define FREG 0#include "fop_template.c"#undef FREG#define FREG 1#include "fop_template.c"#undef FREG#define FREG 2#include "fop_template.c"#undef FREG#define FREG 3#include "fop_template.c"#undef FREG#define FREG 4#include "fop_template.c"#undef FREG#define FREG 5#include "fop_template.c"#undef FREG#define FREG 6#include "fop_template.c"#undef FREG#define FREG 7#include "fop_template.c"#undef FREG#define FREG 8#include "fop_template.c"#undef FREG#define FREG 9#include "fop_template.c"#undef FREG#define FREG 10#include "fop_template.c"#undef FREG#define FREG 11#include "fop_template.c"#undef FREG#define FREG 12#include "fop_template.c"#undef FREG#define FREG 13#include "fop_template.c"#undef FREG#define FREG 14#include "fop_template.c"#undef FREG#define FREG 15#include "fop_template.c"#undef FREG#define FREG 16#include "fop_template.c"#undef FREG#define FREG 17#include "fop_template.c"#undef FREG#define FREG 18#include "fop_template.c"#undef FREG#define FREG 19#include "fop_template.c"#undef FREG#define FREG 20#include "fop_template.c"#undef FREG#define FREG 21#include "fop_template.c"#undef FREG#define FREG 22#include "fop_template.c"#undef FREG#define FREG 23#include "fop_template.c"#undef FREG#define FREG 24#include "fop_template.c"#undef FREG#define FREG 25#include "fop_template.c"#undef FREG#define FREG 26#include "fop_template.c"#undef FREG#define FREG 27#include "fop_template.c"#undef FREG#define FREG 28#include "fop_template.c"#undef FREG#define FREG 29#include "fop_template.c"#undef FREG#define FREG 30#include "fop_template.c"#undef FREG#define FREG 31#include "fop_template.c"#undef FREG#define FTN#include "fop_template.c"#undef FTNvoid op_dup_T0 (void){    T2 = T0;    FORCE_RET();}void op_load_HI (void){    T0 = env->HI[PARAM1][env->current_tc];    FORCE_RET();}void op_store_HI (void){    env->HI[PARAM1][env->current_tc] = T0;    FORCE_RET();}void op_load_LO (void){    T0 = env->LO[PARAM1][env->current_tc];    FORCE_RET();}void op_store_LO (void){    env->LO[PARAM1][env->current_tc] = T0;    FORCE_RET();}/* Load and store */#define MEMSUFFIX _raw#include "op_mem.c"#undef MEMSUFFIX#if !defined(CONFIG_USER_ONLY)#define MEMSUFFIX _user#include "op_mem.c"#undef MEMSUFFIX#define MEMSUFFIX _super#include "op_mem.c"#undef MEMSUFFIX#define MEMSUFFIX _kernel#include "op_mem.c"#undef MEMSUFFIX#endif/* Addresses computation */void op_addr_add (void){/* For compatibility with 32-bit code, data reference in user mode   with Status_UX = 0 should be casted to 32-bit and sign extended.   See the MIPS64 PRA manual, section 4.10. */#if defined(TARGET_MIPS64)    if (((env->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM) &&        !(env->CP0_Status & (1 << CP0St_UX)))        T0 = (int64_t)(int32_t)(T0 + T1);    else#endif        T0 += T1;    FORCE_RET();}/* Arithmetic */void op_add (void){    T0 = (int32_t)((int32_t)T0 + (int32_t)T1);    FORCE_RET();}void op_addo (void){    target_ulong tmp;    tmp = (int32_t)T0;    T0 = (int32_t)T0 + (int32_t)T1;    if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {        /* operands of same sign, result different sign */        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);    }    T0 = (int32_t)T0;    FORCE_RET();}void op_sub (void){    T0 = (int32_t)((int32_t)T0 - (int32_t)T1);    FORCE_RET();}void op_subo (void){    target_ulong tmp;    tmp = (int32_t)T0;    T0 = (int32_t)T0 - (int32_t)T1;    if (((tmp ^ T1) & (tmp ^ T0)) >> 31) {        /* operands of different sign, first operand and result different sign */        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);    }    T0 = (int32_t)T0;    FORCE_RET();}void op_mul (void){    T0 = (int32_t)((int32_t)T0 * (int32_t)T1);    FORCE_RET();}#if HOST_LONG_BITS < 64void op_div (void){    CALL_FROM_TB0(do_div);    FORCE_RET();}#elsevoid op_div (void){    if (T1 != 0) {        env->LO[0][env->current_tc] = (int32_t)((int64_t)(int32_t)T0 / (int32_t)T1);        env->HI[0][env->current_tc] = (int32_t)((int64_t)(int32_t)T0 % (int32_t)T1);    }    FORCE_RET();}#endifvoid op_divu (void){    if (T1 != 0) {        env->LO[0][env->current_tc] = (int32_t)((uint32_t)T0 / (uint32_t)T1);        env->HI[0][env->current_tc] = (int32_t)((uint32_t)T0 % (uint32_t)T1);    }    FORCE_RET();}#if defined(TARGET_MIPS64)/* Arithmetic */void op_dadd (void){    T0 += T1;    FORCE_RET();}void op_daddo (void){    target_long tmp;    tmp = T0;    T0 += T1;    if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 63) {        /* operands of same sign, result different sign */        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);    }    FORCE_RET();}void op_dsub (void){    T0 -= T1;    FORCE_RET();}void op_dsubo (void){    target_long tmp;    tmp = T0;    T0 = (int64_t)T0 - (int64_t)T1;    if (((tmp ^ T1) & (tmp ^ T0)) >> 63) {        /* operands of different sign, first operand and result different sign */        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);    }    FORCE_RET();}void op_dmul (void){    T0 = (int64_t)T0 * (int64_t)T1;    FORCE_RET();}/* Those might call libgcc functions.  */void op_ddiv (void){    do_ddiv();    FORCE_RET();}#if TARGET_LONG_BITS > HOST_LONG_BITSvoid op_ddivu (void){    do_ddivu();    FORCE_RET();}#elsevoid op_ddivu (void){    if (T1 != 0) {        env->LO[0][env->current_tc] = T0 / T1;        env->HI[0][env->current_tc] = T0 % T1;    }    FORCE_RET();}#endif#endif /* TARGET_MIPS64 *//* Logical */void op_and (void){    T0 &= T1;    FORCE_RET();}void op_nor (void){    T0 = ~(T0 | T1);    FORCE_RET();}void op_or (void){    T0 |= T1;    FORCE_RET();}void op_xor (void){    T0 ^= T1;    FORCE_RET();}void op_sll (void){    T0 = (int32_t)((uint32_t)T0 << T1);    FORCE_RET();}void op_sra (void){    T0 = (int32_t)((int32_t)T0 >> T1);    FORCE_RET();}void op_srl (void){    T0 = (int32_t)((uint32_t)T0 >> T1);    FORCE_RET();}void op_rotr (void){    target_ulong tmp;    if (T1) {       tmp = (int32_t)((uint32_t)T0 << (0x20 - T1));       T0 = (int32_t)((uint32_t)T0 >> T1) | tmp;    }    FORCE_RET();}void op_sllv (void){    T0 = (int32_t)((uint32_t)T1 << ((uint32_t)T0 & 0x1F));    FORCE_RET();}void op_srav (void){    T0 = (int32_t)((int32_t)T1 >> (T0 & 0x1F));    FORCE_RET();}void op_srlv (void){    T0 = (int32_t)((uint32_t)T1 >> (T0 & 0x1F));    FORCE_RET();}void op_rotrv (void){    target_ulong tmp;    T0 &= 0x1F;    if (T0) {       tmp = (int32_t)((uint32_t)T1 << (0x20 - T0));       T0 = (int32_t)((uint32_t)T1 >> T0) | tmp;    } else       T0 = T1;    FORCE_RET();}void op_clo (void){    T0 = clo32(T0);    FORCE_RET();}void op_clz (void){    T0 = clz32(T0);    FORCE_RET();}#if defined(TARGET_MIPS64)#if TARGET_LONG_BITS > HOST_LONG_BITS/* Those might call libgcc functions.  */void op_dsll (void){    CALL_FROM_TB0(do_dsll);    FORCE_RET();}void op_dsll32 (void){    CALL_FROM_TB0(do_dsll32);    FORCE_RET();}void op_dsra (void){    CALL_FROM_TB0(do_dsra);    FORCE_RET();}void op_dsra32 (void){    CALL_FROM_TB0(do_dsra32);    FORCE_RET();}void op_dsrl (void){    CALL_FROM_TB0(do_dsrl);    FORCE_RET();}void op_dsrl32 (void){    CALL_FROM_TB0(do_dsrl32);    FORCE_RET();}void op_drotr (void){    CALL_FROM_TB0(do_drotr);    FORCE_RET();}void op_drotr32 (void){    CALL_FROM_TB0(do_drotr32);    FORCE_RET();}void op_dsllv (void){    CALL_FROM_TB0(do_dsllv);    FORCE_RET();}void op_dsrav (void){    CALL_FROM_TB0(do_dsrav);    FORCE_RET();}void op_dsrlv (void){    CALL_FROM_TB0(do_dsrlv);    FORCE_RET();}void op_drotrv (void){    CALL_FROM_TB0(do_drotrv);    FORCE_RET();}void op_dclo (void){    CALL_FROM_TB0(do_dclo);    FORCE_RET();}void op_dclz (void){    CALL_FROM_TB0(do_dclz);    FORCE_RET();}#else /* TARGET_LONG_BITS > HOST_LONG_BITS */void op_dsll (void){    T0 = T0 << T1;    FORCE_RET();}void op_dsll32 (void){    T0 = T0 << (T1 + 32);    FORCE_RET();}void op_dsra (void){    T0 = (int64_t)T0 >> T1;    FORCE_RET();}void op_dsra32 (void){    T0 = (int64_t)T0 >> (T1 + 32);    FORCE_RET();}

⌨️ 快捷键说明

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