📄 mips_emit.h
字号:
/* gameplaySP * * Copyright (C) 2006 Exophase <exophase@gmail.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program 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 * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */#ifndef MIPS_EMIT_H#define MIPS_EMIT_Hu32 mips_update_gba(u32 pc);// Although these are defined as a function, don't call them as// such (jump to it instead)void mips_indirect_branch_arm(u32 address);void mips_indirect_branch_thumb(u32 address);void mips_indirect_branch_dual(u32 address);u32 execute_read_cpsr();u32 execute_read_spsr();void execute_swi(u32 pc);u32 execute_spsr_restore(u32 address);void execute_store_cpsr(u32 new_cpsr, u32 store_mask);void execute_store_spsr(u32 new_spsr, u32 store_mask);u32 execute_spsr_restore_body(u32 address);u32 execute_store_cpsr_body(u32 _cpsr, u32 store_mask, u32 address);u32 execute_lsl_flags_reg(u32 value, u32 shift);u32 execute_lsr_flags_reg(u32 value, u32 shift);u32 execute_asr_flags_reg(u32 value, u32 shift);u32 execute_ror_flags_reg(u32 value, u32 shift);void execute_aligned_store32(u32 address, u32 value);u32 execute_aligned_load32(u32 address);void step_debug_mips(u32 pc);void reg_check();typedef enum{ mips_reg_zero, mips_reg_at, mips_reg_v0, mips_reg_v1, mips_reg_a0, mips_reg_a1, mips_reg_a2, mips_reg_a3, mips_reg_t0, mips_reg_t1, mips_reg_t2, mips_reg_t3, mips_reg_t4, mips_reg_t5, mips_reg_t6, mips_reg_t7, mips_reg_s0, mips_reg_s1, mips_reg_s2, mips_reg_s3, mips_reg_s4, mips_reg_s5, mips_reg_s6, mips_reg_s7, mips_reg_t8, mips_reg_t9, mips_reg_k0, mips_reg_k1, mips_reg_gp, mips_reg_sp, mips_reg_fp, mips_reg_ra} mips_reg_number;typedef enum{ mips_special_sll = 0x00, mips_special_srl = 0x02, mips_special_sra = 0x03, mips_special_sllv = 0x04, mips_special_srlv = 0x06, mips_special_srav = 0x07, mips_special_jr = 0x08, mips_special_jalr = 0x09, mips_special_movz = 0x0A, mips_special_movn = 0x0B, mips_special_mfhi = 0x10, mips_special_mthi = 0x11, mips_special_mflo = 0x12, mips_special_mtlo = 0x13, mips_special_mult = 0x18, mips_special_multu = 0x19, mips_special_div = 0x1A, mips_special_divu = 0x1B, mips_special_madd = 0x1C, mips_special_maddu = 0x1D, mips_special_add = 0x20, mips_special_addu = 0x21, mips_special_sub = 0x22, mips_special_subu = 0x23, mips_special_and = 0x24, mips_special_or = 0x25, mips_special_xor = 0x26, mips_special_nor = 0x27, mips_special_slt = 0x2A, mips_special_sltu = 0x2B} mips_function_special;typedef enum{ mips_special3_ext = 0x00, mips_special3_ins = 0x04, mips_special3_bshfl = 0x20} mips_function_special3;typedef enum{ mips_regimm_bltz = 0x00, mips_regimm_bltzal = 0x10} mips_function_regimm;typedef enum{ mips_opcode_special = 0x00, mips_opcode_regimm = 0x01, mips_opcode_j = 0x02, mips_opcode_jal = 0x03, mips_opcode_beq = 0x04, mips_opcode_bne = 0x05, mips_opcode_blez = 0x06, mips_opcode_bgtz = 0x07, mips_opcode_addi = 0x08, mips_opcode_addiu = 0x09, mips_opcode_slti = 0x0A, mips_opcode_sltiu = 0x0B, mips_opcode_andi = 0x0C, mips_opcode_ori = 0x0D, mips_opcode_xori = 0x0E, mips_opcode_lui = 0x0F, mips_opcode_llo = 0x18, mips_opcode_lhi = 0x19, mips_opcode_trap = 0x1A, mips_opcode_special2 = 0x1C, mips_opcode_special3 = 0x1F, mips_opcode_lb = 0x20, mips_opcode_lh = 0x21, mips_opcode_lw = 0x23, mips_opcode_lbu = 0x24, mips_opcode_lhu = 0x25, mips_opcode_sb = 0x28, mips_opcode_sh = 0x29, mips_opcode_sw = 0x2B,} mips_opcode;#define mips_emit_reg(opcode, rs, rt, rd, shift, function) \ *((u32 *)translation_ptr) = (mips_opcode_##opcode << 26) | \ (rs << 21) | (rt << 16) | (rd << 11) | (shift << 6) | function; \ translation_ptr += 4 \#define mips_emit_special(function, rs, rt, rd, shift) \ *((u32 *)translation_ptr) = (mips_opcode_special << 26) | \ (rs << 21) | (rt << 16) | (rd << 11) | (shift << 6) | \ mips_special_##function; \ translation_ptr += 4 \#define mips_emit_special3(function, rs, rt, imm_a, imm_b) \ *((u32 *)translation_ptr) = (mips_opcode_special3 << 26) | \ (rs << 21) | (rt << 16) | (imm_a << 11) | (imm_b << 6) | \ mips_special3_##function; \ translation_ptr += 4 \#define mips_emit_imm(opcode, rs, rt, immediate) \ *((u32 *)translation_ptr) = (mips_opcode_##opcode << 26) | \ (rs << 21) | (rt << 16) | (immediate & 0xFFFF); \ translation_ptr += 4 \#define mips_emit_regimm(function, rs, immediate) \ *((u32 *)translation_ptr) = (mips_opcode_regimm << 26) | \ (rs << 21) | (mips_regimm_##function << 16) | (immediate & 0xFFFF); \ translation_ptr += 4 \#define mips_emit_jump(opcode, offset) \ *((u32 *)translation_ptr) = (mips_opcode_##opcode << 26) | \ (offset & 0x3FFFFFF); \ translation_ptr += 4 \#define mips_relative_offset(source, offset) \ (((u32)offset - ((u32)source + 4)) / 4) \#define mips_absolute_offset(offset) \ ((u32)offset / 4) \#define mips_emit_addu(rd, rs, rt) \ mips_emit_special(addu, rs, rt, rd, 0) \#define mips_emit_subu(rd, rs, rt) \ mips_emit_special(subu, rs, rt, rd, 0) \#define mips_emit_xor(rd, rs, rt) \ mips_emit_special(xor, rs, rt, rd, 0) \#define mips_emit_add(rd, rs, rt) \ mips_emit_special(and, rs, rt, rd, 0) \#define mips_emit_sub(rd, rs, rt) \ mips_emit_special(sub, rs, rt, rd, 0) \#define mips_emit_and(rd, rs, rt) \ mips_emit_special(and, rs, rt, rd, 0) \#define mips_emit_or(rd, rs, rt) \ mips_emit_special(or, rs, rt, rd, 0) \#define mips_emit_nor(rd, rs, rt) \ mips_emit_special(nor, rs, rt, rd, 0) \#define mips_emit_slt(rd, rs, rt) \ mips_emit_special(slt, rs, rt, rd, 0) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -