diff --git a/sourcepawn/vm/jit/x86/jit_x86.cpp b/sourcepawn/vm/jit/x86/jit_x86.cpp index 604578da..1a302586 100644 --- a/sourcepawn/vm/jit/x86/jit_x86.cpp +++ b/sourcepawn/vm/jit/x86/jit_x86.cpp @@ -951,7 +951,7 @@ inline void WriteOp_Cmps(JitWriter *jit) //sbb eax, eax //sbb eax, -1 IA32_Sbb_Rm_Reg(jit, REG_EAX, REG_EAX, MOD_REG); - IA32_Sbb_Eax_Imm32(jit, -1); + IA32_Sbb_Eax_Imm32(jit, -1);//:TODO: use imm8 here //:cmps1 //pop esi @@ -1077,12 +1077,12 @@ inline void WriteOp_Lodb_I(JitWriter *jit) { case 1: { - IA32_And_Rm_Imm32(jit, AMX_REG_PRI, 0x000000FF); + IA32_And_Rm_Imm32(jit, AMX_REG_PRI, 0x000000FF);//:TODO: replace with AND EAX, imm32 break; } case 2: { - IA32_And_Rm_Imm32(jit, AMX_REG_PRI, 0x0000FFFF); + IA32_And_Rm_Imm32(jit, AMX_REG_PRI, 0x0000FFFF);//:TODO: replace with AND EAX, imm32 break; } } @@ -1112,7 +1112,7 @@ inline void WriteOp_Strb_I(JitWriter *jit) IA32_Mov_Rm16_Reg_Disp_Reg(jit, AMX_REG_DAT, AMX_REG_ALT, NOSCALE, AMX_REG_PRI); break; } - case 3: + case 4: { IA32_Mov_Rm_Reg_Disp_Reg(jit, AMX_REG_DAT, AMX_REG_ALT, NOSCALE, AMX_REG_PRI); break; @@ -1222,7 +1222,7 @@ inline void WriteOp_Sctrl(JitWriter *jit) { //mov ebx, eax - overwrite frm //mov frm, eax - overwrite stacked frame - //add ebx, edi - relocate local frm + //add ebx, edi - relocate local frm //:TODO: use LEA here!!! IA32_Mov_Reg_Rm(jit, AMX_REG_FRM, AMX_REG_PRI, MOD_REG); IA32_Mov_Rm_Reg(jit, AMX_INFO_FRM, AMX_REG_PRI, MOD_MEM_REG); IA32_Add_Rm_Reg(jit, AMX_REG_FRM, AMX_REG_DAT, MOD_REG); @@ -1325,7 +1325,7 @@ inline void WriteOp_Ret(JitWriter *jit) //ret IA32_Mov_Reg_Rm(jit, AMX_REG_FRM, AMX_REG_STK, MOD_MEM_REG); IA32_Add_Rm_Imm8(jit, AMX_REG_STK, 4, MOD_REG); - IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_INFO, AMX_REG_FRM, AMX_INFO_FRM); + IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_INFO, AMX_REG_FRM, AMX_INFO_FRM);//:TODO: this is wrong! IA32_Add_Rm_Reg(jit, AMX_REG_FRM, AMX_REG_DAT, MOD_REG); IA32_Return(jit); } @@ -1340,7 +1340,7 @@ inline void WriteOp_Retn(JitWriter *jit) IA32_Mov_Reg_Rm(jit, AMX_REG_FRM, AMX_REG_STK, MOD_MEM_REG); IA32_Mov_Reg_Rm_Disp8(jit, AMX_REG_TMP, AMX_REG_STK, 4); IA32_Add_Rm_Imm8(jit, AMX_REG_STK, 8, MOD_REG); - IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_INFO, AMX_REG_FRM, AMX_INFO_FRM); + IA32_Mov_Rm_Reg_Disp8(jit, AMX_REG_INFO, AMX_REG_FRM, AMX_INFO_FRM);//:TODO: this is wrong! IA32_Add_Rm_Reg(jit, AMX_REG_FRM, AMX_REG_DAT, MOD_REG); //add ebp, [ebp] - reduce by this # of params diff --git a/sourcepawn/vm/jit/x86/opcode_helpers.cpp b/sourcepawn/vm/jit/x86/opcode_helpers.cpp index b1ce1b45..f6c2d3ff 100644 --- a/sourcepawn/vm/jit/x86/opcode_helpers.cpp +++ b/sourcepawn/vm/jit/x86/opcode_helpers.cpp @@ -283,7 +283,7 @@ void Write_BoundsCheck(JitWriter *jit) //cmp eax, ecx //jg :err_bounds //ret - IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, 0); + IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, 0);//:TODO: use imm8 jitoffs_t jmp1 = IA32_Jump_Cond_Imm8(jit, CC_L, 0); //:TODO: make sure this is right order IA32_Cmp_Rm_Reg(jit, AMX_REG_PRI, AMX_REG_TMP, MOD_REG); @@ -296,11 +296,11 @@ void Write_BoundsCheck(JitWriter *jit) } else { //cmp eax, 0 //jl :err_bounds - IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, 0); + IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, 0);//:TODO: use imm8 jitoffs_t jmp1 = IA32_Jump_Cond_Imm8(jit, CC_L, 0); //cmp eax, //jg :err_bounds - IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, jit->read_cell()); + IA32_Cmp_Rm_Imm32(jit, MOD_REG, AMX_REG_PRI, jit->read_cell());//:TODO:check val size and use cmp eax or imm8 jitoffs_t jmp2 = IA32_Jump_Cond_Imm8(jit, CC_G, 0); //jmp :continue jitoffs_t cont = IA32_Jump_Imm8(jit, 0); diff --git a/sourcepawn/vm/jit/x86/x86_macros.h b/sourcepawn/vm/jit/x86/x86_macros.h index 9d69db42..8083ee95 100644 --- a/sourcepawn/vm/jit/x86/x86_macros.h +++ b/sourcepawn/vm/jit/x86/x86_macros.h @@ -579,11 +579,11 @@ inline void IA32_Popad(JitWriter *jit) jit->write_ubyte(IA32_POPAD); } -inline void IA32_Push_Rm_Disp8(JitWriter *jit, jit_uint8_t reg, jit_uint8_t disp8) +inline void IA32_Push_Rm_Disp8(JitWriter *jit, jit_uint8_t reg, jit_int8_t disp8) { jit->write_ubyte(IA32_PUSH_RM); jit->write_ubyte(ia32_modrm(MOD_DISP8, 6, reg)); - jit->write_ubyte(disp8); // :TODO: is it ubyte or byte?? + jit->write_byte(disp8); } /** @@ -871,11 +871,11 @@ inline void IA32_Cmp_Rm_Imm32(JitWriter *jit, jit_uint8_t mode, jit_uint8_t rm, jit->write_int32(imm32); } -inline void IA32_Cmp_Rm_Imm32_Disp8(JitWriter *jit, jit_uint8_t reg, jit_uint8_t disp8, jit_int32_t imm32) +inline void IA32_Cmp_Rm_Imm32_Disp8(JitWriter *jit, jit_uint8_t reg, jit_int8_t disp8, jit_int32_t imm32) { jit->write_ubyte(IA32_CMP_RM_IMM32); jit->write_ubyte(ia32_modrm(MOD_DISP8, 7, reg)); - jit->write_ubyte(disp8); + jit->write_byte(disp8); jit->write_int32(imm32); }