diff --git a/src/codegen_ops_fpu.h b/src/codegen_ops_fpu.h index 47a7a03..70da3dd 100644 --- a/src/codegen_ops_fpu.h +++ b/src/codegen_ops_fpu.h @@ -481,8 +481,7 @@ static uint32_t ropFCOMPP(uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uin { FP_ENTER(); FP_COMPARE_REG(0, 1); - FP_POP(); - FP_POP(); + FP_POP2(); return op_pc; } diff --git a/src/codegen_ops_x86-64.h b/src/codegen_ops_x86-64.h index 5c834e7..5026812 100644 --- a/src/codegen_ops_x86-64.h +++ b/src/codegen_ops_x86-64.h @@ -3908,6 +3908,26 @@ static void FP_POP() addbyte(0x45); addbyte(cpu_state_offset(TOP)); } +static void FP_POP2() +{ + addbyte(0x8b); /*MOV EAX, [TOP]*/ + addbyte(0x45); + addbyte(cpu_state_offset(TOP)); + addbyte(0xc6); /*MOVB tag[EAX], 3*/ + addbyte(0x44); + addbyte(0x05); + addbyte(cpu_state_offset(tag)); + addbyte(3); + addbyte(0x83); /*ADD AL, 2*/ + addbyte(0xc0); + addbyte(2); + addbyte(0x83); /*AND AL, 7*/ + addbyte(0xe0); + addbyte(7); + addbyte(0x89); /*MOV [TOP], EAX*/ + addbyte(0x45); + addbyte(cpu_state_offset(TOP)); +} static void FP_LOAD_S() { diff --git a/src/codegen_ops_x86.h b/src/codegen_ops_x86.h index caf1c3c..845a528 100644 --- a/src/codegen_ops_x86.h +++ b/src/codegen_ops_x86.h @@ -2503,6 +2503,42 @@ static void FP_POP() addbyte(cpu_state_offset(TOP)); } } +static void FP_POP2() +{ + if (codeblock[block_current].flags & CODEBLOCK_STATIC_TOP) + { + addbyte(0xc6); /*MOVB tag[0][EBP], 3*/ + addbyte(0x45); + addbyte(cpu_state_offset(tag[cpu_state.TOP])); + addbyte(3); + addbyte(0xc6); /*MOVB tag[1][EBP], 3*/ + addbyte(0x45); + addbyte(cpu_state_offset(tag[(cpu_state.TOP+1)&7])); + addbyte(3); + addbyte(0xc6); /*MOVB TOP[EBP], (TOP+2) & 7*/ + addbyte(0x45); + addbyte(cpu_state_offset(TOP)); + addbyte((cpu_state.TOP + 2) & 7); + } + else + { + addbyte(0x8b); /*MOV EAX, TOP*/ + addbyte(0x45); + addbyte(cpu_state_offset(TOP)); + addbyte(0xc6); /*MOVB tag[EAX], 3*/ + addbyte(0x44); + addbyte(0x05); + addbyte(cpu_state_offset(tag[0])); + addbyte(3); + addbyte(0x04); /*ADD AL, 2*/ + addbyte(2); + addbyte(0x24); /*AND AL, 7*/ + addbyte(7); + addbyte(0x88); /*MOV TOP, AL*/ + addbyte(0x45); + addbyte(cpu_state_offset(TOP)); + } +} #define FPU_ADD 0x00 #define FPU_DIV 0x30