emit_extjump2(addr, target, (int)dyna_linker_ds);
}
-#ifdef PCSX
-#include "pcsxmem_inline.c"
-#endif
+// put rt_val into rt, potentially making use of rs with value rs_val
+static void emit_movimm_from(u_int rs_val,int rs,u_int rt_val,int rt)
+{
+ u_int xor=rs_val^rt_val;
+ u_int xs;
+ for(xs=xor;xs!=0&&(xs&3)==0;xs>>=2)
+ ;
+ if(xs<0x100)
+ emit_xorimm(rs,xor,rt);
+ else
+ emit_movimm(rt_val,rt);
+}
// trashes r2
static void pass_args(int a0, int a1)
assert(rs>=0);
#ifdef PCSX
u_int handler,host_addr=0;
- if(pcsx_direct_read(type,addr,target?rs:-1,rt))
- return;
handler=get_direct_memhandler(mem_rtab,addr,type,&host_addr);
if (handler==0) {
if(rt<0)
return;
- if(target==0||addr!=host_addr)
- emit_movimm(host_addr,rs);
+ if(addr!=host_addr)
+ emit_movimm_from(addr,rs,host_addr,rs);
switch(type) {
case LOADB_STUB: emit_movsbl_indexed(0,rs,rt); break;
case LOADBU_STUB: emit_movzbl_indexed(0,rs,rt); break;
assert(rt>=0);
#ifdef PCSX
u_int handler,host_addr=0;
- if(pcsx_direct_write(type,addr,rs,rt,regmap))
- return;
handler=get_direct_memhandler(mem_wtab,addr,type,&host_addr);
if (handler==0) {
- if(target==0||addr!=host_addr)
- emit_movimm(host_addr,rs);
+ if(addr!=host_addr)
+ emit_movimm_from(addr,rs,host_addr,rs);
switch(type) {
case STOREB_STUB: emit_writebyte_indexed(rt,0,rs); break;
case STOREH_STUB: emit_writehword_indexed(rt,0,rs); break;
// call a memhandler
save_regs(reglist);
- pass_args(target!=0?rs:-1,rt);
- if(target==0)
- emit_movimm(addr,0);
+ pass_args(rs,rt);
int cc=get_reg(regmap,CCREG);
if(cc<0)
emit_loadreg(CCREG,2);
+++ /dev/null
-/*
- * (C) GraÅžvydas "notaz" Ignotas, 2011
- *
- * This work is licensed under the terms of GNU GPL version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-static int emit_ldr_type(int type, int offs, int rs, int rt)
-{
- switch(type) {
- case LOADB_STUB:
- emit_movsbl_indexed(offs,rs,rt);
- break;
- case LOADBU_STUB:
- emit_movzbl_indexed(offs,rs,rt);
- break;
- case LOADH_STUB:
- emit_movswl_indexed(offs,rs,rt);
- break;
- case LOADHU_STUB:
- emit_movzwl_indexed(offs,rs,rt);
- break;
- case LOADW_STUB:
- emit_readword_indexed(offs,rs,rt);
- break;
- default:
- assert(0);
- }
-}
-
-static int emit_str_type(int type, int offs, int rs, int rt)
-{
- switch(type) {
- case STOREB_STUB:
- emit_writebyte_indexed(rt,offs,rs);
- break;
- case STOREH_STUB:
- emit_writehword_indexed(rt,offs,rs);
- break;
- case STOREW_STUB:
- emit_writeword_indexed(rt,offs,rs);
- break;
- default:
- assert(0);
- }
-}
-
-static void convert_ram_addr(u_int a_rs, u_int a_rt, int rs, int rt)
-{
- if(rs<0)
- emit_movimm(a_rt,rt);
- else if((a_rs&~0x60000000)==a_rt)
- emit_andimm(rs,~0x60000000,rt);
- else if((a_rs&~0x00600000)==a_rt)
- emit_andimm(rs,~0x00600000,rt);
- else
- emit_movimm(a_rt,rt);
-}
-
-static int pcsx_direct_read(int type, u_int addr, int rs, int rt)
-{
- if((addr & 0x1f800000) == 0) {
- assem_debug("pcsx_direct_read %08x ram\n",addr);
- if(rt<0)
- return 1;
- u_int a=(addr&~0x60600000)|0x80000000;
- convert_ram_addr(addr,a,rs,rt);
- emit_ldr_type(type,0,rt,rt);
- return 1;
- }
- if((addr & 0x1ff80000) == 0x1fc00000) {
- assem_debug("pcsx_direct_read %08x bios\n",addr);
- if(rt<0)
- return 1;
- emit_movimm((u_int)&psxR[addr&0x7ffff],rt);
- emit_ldr_type(type,0,rt,rt);
- return 1;
- }
- if((addr & 0xfffff000) == 0x1f800000) {
- assem_debug("pcsx_direct_read %08x scratchpad\n",addr);
- if(rt<0)
- return 1;
- if(type==LOADW_STUB||type==LOADBU_STUB||(addr&0xf00)==0) {
- emit_readword((int)&psxH_ptr,rt);
- emit_ldr_type(type,addr&0xfff,rt,rt);
- } else {
- emit_movimm((u_int)&psxH[addr&0xfff],rt);
- emit_ldr_type(type,0,rt,rt);
- }
- return 1;
- }
-
- assem_debug("pcsx_direct_read %08x miss\n",addr);
- return 0;
-}
-
-static int pcsx_direct_write(int type, u_int addr, int rs, int rt, signed char *regmap)
-{
- if((addr & 0x1f800000) == 0) {
- assem_debug("pcsx_direct_write %08x ram\n",addr);
- u_int a=(addr&~0x60600000)|0x80000000;
- convert_ram_addr(addr,a,rs,HOST_TEMPREG);
- emit_str_type(type,0,HOST_TEMPREG,rt);
-
- int ir=get_reg(regmap,INVCP);
- assert(ir>=0);
- emit_cmpmem_indexedsr12_reg(ir,HOST_TEMPREG,1);
- emit_callne(invalidate_addr_reg[rs]);
- return 1;
- }
- if((addr & 0xfffff000) == 0x1f800000) {
- assem_debug("pcsx_direct_write %08x scratchpad\n",addr);
- if(type==STOREW_STUB||type==STOREB_STUB||(addr&0xf00)==0) {
- emit_readword((int)&psxH_ptr,HOST_TEMPREG);
- emit_str_type(type,addr&0xfff,HOST_TEMPREG,rt);
- } else {
- emit_movimm((u_int)&psxH[addr&0xfff],HOST_TEMPREG);
- emit_str_type(type,0,HOST_TEMPREG,rt);
- }
- return 1;
- }
-
- assem_debug("pcsx_direct_write %08x miss\n",addr);
- return 0;
-}
-
-// vim:shiftwidth=2:expandtab