PCSX2 Documentation/Introduction to Dynamic Recompilation: Difference between revisions
Jump to navigation
Jump to search
PCSX2 Documentation/Introduction to Dynamic Recompilation (view source)
Revision as of 07:13, 8 January 2022
, 8 January 2022Get rid of html entity (&), use & instead
No edit summary |
(Get rid of html entity (&), use & instead) Tags: Mobile edit Mobile web edit |
||
(3 intermediate revisions by one other user not shown) | |||
Line 6: | Line 6: | ||
Lets assume the processor we are emulating is a made-up chip I'll call SL3 (super lame 3), and has only these 3 instructions (and each instruction has fixed width of 4 bytes): | Lets assume the processor we are emulating is a made-up chip I'll call SL3 (super lame 3), and has only these 3 instructions (and each instruction has fixed width of 4 bytes): | ||
< | <source lang="asm"> | ||
MOV dest_reg, src1_reg // Move source register to destination register | MOV dest_reg, src1_reg // Move source register to destination register | ||
ADD dest_reg, src1_reg, src2_reg // Add source1 and source2 registers, and store the result in destination register | ADD dest_reg, src1_reg, src2_reg // Add source1 and source2 registers, and store the result in destination register | ||
Line 74: | Line 74: | ||
The code for actually recompiling these blocks looks something like this: | The code for actually recompiling these blocks looks something like this: | ||
<source lang=" | <source lang="cpp"> | ||
// This is our emulated MOV instruction | // This is our emulated MOV instruction | ||
void MOV() { | void MOV() { | ||
Line 80: | Line 80: | ||
u8 reg1 = fetch(); // Get source 1 register number | u8 reg1 = fetch(); // Get source 1 register number | ||
xMOV(eax, ptr[& | xMOV(eax, ptr[&cpuRegs[reg1]]); // Move reg1's data to eax | ||
xMOV(ptr[& | xMOV(ptr[&cpuRegs[dest]], eax); // Move eax to dest register | ||
fetch(); // This fetch is needed because every instruction in our SL3 processor is 4 bytes | fetch(); // This fetch is needed because every instruction in our SL3 processor is 4 bytes | ||
Line 92: | Line 92: | ||
u8 reg2 = fetch(); // Get source 2 register number | u8 reg2 = fetch(); // Get source 2 register number | ||
xMOV(eax, ptr[& | xMOV(eax, ptr[&cpuRegs[reg1]]); // Move reg1's data to eax | ||
xADD(eax, ptr[& | xADD(eax, ptr[&cpuRegs[reg2]]); // Add eax with reg2's data | ||
xMOV(ptr[& | xMOV(ptr[&cpuRegs[dest]], eax); // Move eax to dest register | ||
} | } | ||
Line 190: | Line 190: | ||
*newVIF unpack recompiler (recompiles vif unpack routines) | *newVIF unpack recompiler (recompiles vif unpack routines) | ||
*r3000air (not yet finished, but should one day supersede the IOP recompiler) | *r3000air (not yet finished, but should one day supersede the IOP recompiler) | ||
{{PCSX2 Documentation Navbox}} | {{PCSX2 Documentation Navbox}} |