📄 jit3-m68k.def
字号:
/* jit-m68k.def * M68000 instruction definition. * * Copyright (c) 1996, 1997 * Transvirtual Technologies, Inc. All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file. */#define KAFFE_VMDEBUG#include <assert.h>#include <string.h>#include "classMethod.h"#include "access.h"#include "soft.h"#define REG_d0 0#define REG_d1 1#define REG_a0 8#define REG_fp 14#define REG_sp 15#define REG_fp0 16#ifdef KAFFE_VMDEBUGstatic const char * const rnames[] = { "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp", "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7",};#define regname(n) rnames[n]#endif#define assert_dreg(x) assert(x >= 0 && x <= 7)#define assert_areg(x) assert(x >= 8 && x <= 15)#define assert_freg(x) assert(x >= 16 && x <= 23)#define assert_s8(x) assert(x >= -0x80 && x < 0x80)#define assert_s16(x) assert(x >= -0x8000 && x < 0x8000)#define LSLOT(s) ((s)+1)#define HSLOT(s) (s)/* FIXME -- detecting 68040 properly lets us do fp to IEEE spec. */#define is_68040 0/* --------------------------------------------------------------------- *//* Instruction assembly *//* Here we make implementing the instructions a bit easier, but calling them slightly more difficult, by sending specific modes to each insn variant. These are encoded in the suffix of the function name like so: d data register a address register f floating point register i immediate I address register indirect o address register indirect with displacement p address register indirect with predecrement x address register indirect with index & 8-bit displacement*/#ifdef KAFFE_VMDEBUGint jit_debug = 0;#define debug(x) (jit_debug ? printf("%x:\t", (int)CODEPC), printf x : 0)#else#define debug(x) ((void)0)#endif#define MODE_d 0#define MODE_a 1#define MODE_ind 2#define MODE_postinc 3#define MODE_predec 4#define MODE_inddisp 5#define MODE_index 6#define MODE_src_imm 074#define MODE_src_absw 070#define MODE_src_absl 071#define OPMODE_s (is_68040 ? 0x40 : 0)#define OPMODE_d (is_68040 ? 0x44 : 0)#define COPROCID 1static inline voidop_addl_id(int imm, int dst){ debug(("addl #%d, %s\n", imm, regname(dst))); assert_dreg(dst); WOUT = 0xD080 | (dst << 9) | MODE_src_imm; LOUT = imm;}static inline voidop_addl_dd(int src, int dst){ debug(("addl %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_dreg(dst); WOUT = 0xD080 | (dst << 9) | (MODE_d << 3) | (src & 7);}#if !defined(HAVE_NO_ADDAW)static inline voidop_addaw_ia(int imm, int dst){ debug(("addaw #%d, %s\n", imm, regname(dst))); assert_s16(imm); assert_areg(dst); WOUT = 0xD0C0 | ((dst & 7) << 9) | MODE_src_imm; WOUT = imm;}#endifstatic inline voidop_addal_ia(int imm, int dst){ debug(("addal #%d, %s\n", imm, regname(dst))); assert_areg(dst); WOUT = 0xD1C0 | ((dst & 7) << 9) | MODE_src_imm; LOUT = imm;}static inline voidop_addal_da(int src, int dst){ debug(("addal %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_areg(dst); WOUT = 0xD1C0 | ((dst & 7) << 9) | (MODE_d << 3) | (src & 7);}static inline voidop_addql_ia(int imm, int dst){ debug(("addql #%d, %s\n", imm, regname(dst))); assert(imm >= 1 && imm <= 8); assert_areg(dst); WOUT = 0x5080 | ((imm & 7) << 9) | (MODE_a << 3) | (dst & 7);}static inline voidop_addql_id(int imm, int dst){ debug(("addql #%d, %s\n", imm, regname(dst))); assert(imm >= 1 && imm <= 8); assert_dreg(dst); WOUT = 0x5080 | ((imm & 7) << 9) | (MODE_d << 3) | (dst & 7);}static inline voidop_addxl_dd(int src, int dst){ debug(("addxl %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_dreg(dst); WOUT = 0xD180 | (dst << 9) | src;}static inline voidop_andl_id(int imm, int dst){ debug(("andl #0x%x, %s\n", imm, regname(dst))); assert_dreg(dst); WOUT = 0xC080 | (dst << 9) | MODE_src_imm; LOUT = imm;}static inline voidop_andl_dd(int src, int dst){ debug(("andl %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_dreg(dst); WOUT = 0xC080 | (dst << 9) | (MODE_d << 3) | (src & 7);}static inline voidop_asr_id(int imm, int dst){ debug(("asr #%d, %s\n", imm, regname(dst))); assert_dreg(dst); assert(imm >= 1 && imm <= 8); WOUT = 0xE080 | ((imm & 7) << 9) | dst;}static inline voidop_asr_dd(int src, int dst){ debug(("asr %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_dreg(dst); WOUT = 0xE0A0 | ((src & 7) << 9) | dst;}static inline voidop_blo_16(int disp){ debug(("blo %+d\n", disp)); WOUT = 0x6500; WOUT = disp;}#if defined(HAVE_NO_LONG_BRANCHES)static inline voidop_beq_16(int disp){ debug(("beq %+d\n", disp)); WOUT = 0x6700; WOUT = disp;}static inline voidop_bne_16(int disp){ debug(("bne %+d\n", disp)); WOUT = 0x6600; WOUT = disp;}static inline voidop_blt_16(int disp){ debug(("blt %+d\n", disp)); WOUT = 0x6D00; WOUT = disp;}static inline voidop_ble_16(int disp){ debug(("ble %+d\n", disp)); WOUT = 0x6F00; WOUT = disp;}static inline voidop_bgt_16(int disp){ debug(("bgt %+d\n", disp)); WOUT = 0x6E00; WOUT = disp;}static inline voidop_bge_16(int disp){ debug(("bge %+d\n", disp)); WOUT = 0x6C00; WOUT = disp;}static inline voidop_bra_16(int disp){ debug(("bra %+d\n", disp)); WOUT = 0x6000; WOUT = disp;}#elsestatic inline voidop_beq_32(int disp){ debug(("beq %+d\n", disp)); WOUT = 0x67FF; LOUT = disp;}static inline voidop_bne_32(int disp){ debug(("bne %+d\n", disp)); WOUT = 0x66FF; LOUT = disp;}static inline voidop_blt_32(int disp){ debug(("blt %+d\n", disp)); WOUT = 0x6DFF; LOUT = disp;}static inline voidop_ble_32(int disp){ debug(("ble %+d\n", disp)); WOUT = 0x6FFF; LOUT = disp;}static inline voidop_bgt_32(int disp){ debug(("bgt %+d\n", disp)); WOUT = 0x6EFF; LOUT = disp;}static inline voidop_bge_32(int disp){ debug(("bge %+d\n", disp)); WOUT = 0x6CFF; LOUT = disp;}static inline voidop_blo_32(int disp){ debug(("blo %+d\n", disp)); WOUT = 0x65FF; LOUT = disp;}static inline voidop_bra_32(int disp){ debug(("bra %+d\n", disp)); WOUT = 0x60FF; LOUT = disp;}#endifstatic inline voidop_jsr_32(int disp){ debug(("jsr %+d\n", disp)); WOUT = 0x4EB9; LOUT = disp;}static inline voidop_clrl_d(int dst){ debug(("clrl %s\n", regname(dst))); assert_dreg(dst); WOUT = 0x4280 | (MODE_d << 3) | (dst & 7);}static inline voidop_cmpl_dd(int src1, int src2){ debug(("cmpl %s, %s\n", regname(src1), regname(src2))); assert_dreg(src1); assert_dreg(src2); WOUT = 0xB080 | (src2 << 9) | (MODE_d << 7) | (src1 & 7);}static inline voidop_cmpal_aa(int src1, int src2){ debug(("cmpl %s, %s\n", regname(src1), regname(src2))); assert_areg(src1); assert_areg(src2); WOUT = 0xB1C0 | (src2 << 9) | (MODE_a << 3) | (src1 & 7);}static inline voidop_cmpil_ia(int imm, int src2){ debug(("cmpil #%d, %s\n", imm, regname(src2))); assert_areg(src2); WOUT = 0x0C80 | (MODE_a << 3) | (src2 & 7); LOUT = imm;}static inline voidop_cmpil_id(int imm, int src2){ debug(("cmpil #%d, %s\n", imm, regname(src2))); assert_dreg(src2); WOUT = 0x0C80 | (MODE_d << 3) | (src2 & 7); LOUT = imm;}static inline voidop_divsl_ddd(int src, int r, int q){ debug(("divsl %s, %s:%s\n", regname(src), regname(r), regname(q))); assert_dreg(src); assert_dreg(r); assert_dreg(q); WOUT = 0x4C40 | (MODE_d << 3) | (src & 7); WOUT = 0x0800 | (q << 12) | r;}static inline voidop_eorl_dd(int src, int dst){ debug(("eorl %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_dreg(dst); WOUT = 0xB180 | ((src & 7) << 9) | (MODE_d << 3) | (dst & 7);}static inline voidop_extbl_d(int dst){ debug(("extbl %s\n", regname(dst))); assert_dreg(dst); WOUT = 0x49C0 | dst;}static inline voidop_extwl_d(int dst){ debug(("extwl %s\n", regname(dst))); assert_dreg(dst); WOUT = 0x48C0 | dst;}#if !defined(HAVE_NO_EXG)static inline voidop_exg_aa(int r1, int r2){ debug(("exg %s, %s\n", regname(r1), regname(r2))); assert_areg(r1); assert_areg(r2); WOUT = 0xC148 | ((r1 & 7) << 9) | (r2 & 7);}static inline voidop_exg_da(int r1, int r2){ debug(("exg %s, %s\n", regname(r1), regname(r2))); assert_dreg(r1); assert_areg(r2); WOUT = 0xC188 | (r1 << 9) | (r2 & 7);}static inline voidop_exg_dd(int r1, int r2){ debug(("exg %s, %s\n", regname(r1), regname(r2))); assert_dreg(r1); assert_dreg(r2); WOUT = 0xC140 | (r1 << 9) | r2;}#endifstatic inline voidop_jmp_I(int dst){ debug(("jmp (%s)\n", regname(dst))); assert_areg(dst); WOUT = 0x4EC0 | (MODE_ind << 3) | (dst & 7);}static inline voidop_jsr_I(int dst){ debug(("jsr (%s)\n", regname(dst))); assert_areg(dst); WOUT = 0x4E80 | (MODE_ind << 3) | (dst & 7);}static inline voidop_linkw_ai(int areg, int disp){ debug(("linkw %s, #%d\n", regname(areg), disp)); assert_s16(disp); assert_areg(areg); WOUT = 0x4E50 | (areg & 7); WOUT = disp;}static inline voidop_lsl_id(int imm, int dst){ debug(("lsl #%d, %s\n", imm, regname(dst))); assert_dreg(dst); assert(imm >= 1 && imm <= 8); WOUT = 0xE188 | ((imm & 7) << 9) | dst;}static inline voidop_lsl_dd(int src, int dst){ debug(("lsl %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_dreg(dst); WOUT = 0xE1A8 | ((src & 7) << 9) | dst;}static inline voidop_lsr_id(int imm, int dst){ debug(("lsr #%d, %s\n", imm, regname(dst))); assert_dreg(dst); assert(imm >= 1 && imm <= 8); WOUT = 0xE088 | ((imm & 7) << 9) | dst;}static inline voidop_lsr_dd(int src, int dst){ debug(("lsr %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_dreg(dst); WOUT = 0xE0A8 | ((src & 7) << 9) | dst;}static inline voidop_moveb_Id(int src, int dst){ debug(("moveb (%s), %s\n", regname(src), regname(dst))); assert_areg(src); assert_dreg(dst); WOUT = (0x1000 | ((dst & 7) << 9) | (MODE_d << 6) | (MODE_ind << 3) | (src & 7));}static inline voidop_moveb_dI(int src, int dst){ debug(("moveb %s, (%s)\n", regname(src), regname(dst))); assert_dreg(src); assert_areg(dst); WOUT = (0x1000 | ((dst & 7) << 9) | (MODE_ind << 6) | (MODE_d << 3) | (src & 7));}static inline voidop_movew_Id(int src, int dst){ debug(("movew (%s), %s\n", regname(src), regname(dst))); assert_areg(src); assert_dreg(dst); WOUT = (0x3000 | ((dst & 7) << 9) | (MODE_d << 6) | (MODE_ind << 3) | (src & 7));}static inline voidop_movew_dI(int src, int dst){ debug(("movew %s, (%s)\n", regname(src), regname(dst))); assert_dreg(src); assert_areg(dst); WOUT = (0x3000 | ((dst & 7) << 9) | (MODE_ind << 6) | (MODE_d << 3) | (src & 7));}static inline voidop_movel_ao(int src, int base, int disp){ debug(("movel %s, %d(%s)\n", regname(src), disp, regname(base))); assert_areg(src); assert_areg(base); assert_s16(disp); WOUT = (0x2000 | ((base & 7) << 9) | (MODE_inddisp << 6) | (MODE_a << 3) | (src & 7)); WOUT = disp;}static inline voidop_movel_ad(int src, int dst){ debug(("movel %s, %s\n", regname(src), regname(dst))); assert_areg(src); assert_dreg(dst); WOUT = (0x2000 | ((dst & 7) << 9) | (MODE_d << 6) | (MODE_a << 3) | (src & 7));}static inline voidop_movel_da(int src, int dst){ debug(("movel %s, %s\n", regname(src), regname(dst))); assert_areg(src); assert_dreg(dst); WOUT = (0x2000 | ((dst & 7) << 9) | (MODE_a << 6) | (MODE_d << 3) | (src & 7));}static inline voidop_movel_dd(int src, int dst){ debug(("movel %s, %s\n", regname(src), regname(dst))); assert_dreg(src); assert_dreg(dst); WOUT = (0x2000 | ((dst & 7) << 9) | (MODE_d << 6) | (MODE_d << 3) | (src & 7));}static inline voidop_movel_do(int src, int base, int disp){ debug(("movel %s, %d(%s)\n", regname(src), disp, regname(base))); assert_dreg(src); assert_areg(base); assert_s16(disp); WOUT = (0x2000 | ((base & 7) << 9) | (MODE_inddisp << 6) | (MODE_d << 3) | (src & 7)); WOUT = disp;}static inline voidop_movel_id(int imm, int dst){ debug(("movel #%d, %s\n", imm, regname(dst))); assert_dreg(dst); WOUT = 0x2000 | ((dst & 7) << 9) | (MODE_d << 6) | MODE_src_imm; LOUT = imm;}static inline voidop_movel_Id(int src, int dst){ debug(("movel (%s), %s\n", regname(src), regname(dst))); assert_areg(src); assert_dreg(dst); WOUT = (0x2000 | ((dst & 7) << 9) | (MODE_d << 6) | (MODE_ind << 3) | (src & 7));}static inline voidop_movel_aI(int src, int dst){ debug(("movel %s, (%s)\n", regname(src), regname(dst))); assert_areg(src); assert_areg(dst); WOUT = (0x2000 | ((dst & 7) << 9) | (MODE_ind << 6) | (MODE_a << 3) | (src & 7));}static inline voidop_movel_dI(int src, int dst){ debug(("movel %s, (%s)\n", regname(src), regname(dst))); assert_dreg(src); assert_areg(dst); WOUT = (0x2000 | ((dst & 7) << 9) | (MODE_ind << 6) | (MODE_d << 3) | (src & 7));}static inline voidop_movel_ip(int imm, int dst){ debug(("movel #%d, -(%s)\n", imm, regname(dst))); assert_areg(dst);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -