mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
committed OP_FLOAT_CMP
This commit is contained in:
parent
eba5b1a920
commit
e74ff6a5a4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -272,6 +272,7 @@ typedef enum {
|
||||
OP_FLOAT_SUB,
|
||||
OP_FLOAT_TO,
|
||||
OP_FLOAT_ROUND,
|
||||
OP_FLOAT_CMP,
|
||||
/* ----- */
|
||||
OP_NUM_OPCODES
|
||||
} OPCODE;
|
||||
@ -698,6 +699,7 @@ static int amx_BrowseRelocate(AMX *amx)
|
||||
case OP_FLOAT_SUB:
|
||||
case OP_FLOAT_TO:
|
||||
case OP_FLOAT_ROUND:
|
||||
case OP_FLOAT_CMP:
|
||||
break;
|
||||
|
||||
case OP_CALL: /* opcodes that need relocation */
|
||||
@ -1764,14 +1766,15 @@ static const void * const amx_opcodelist[] = {
|
||||
&&op_jump_pri, &&op_switch, &&op_casetbl, &&op_swap_pri,
|
||||
&&op_swap_alt, &&op_pushaddr, &&op_nop, &&op_sysreq_d,
|
||||
&&op_symtag, &&op_break, &&op_float_mul, &&op_float_div,
|
||||
&&op_float_add, &&op_float_sub, &&op_float_to, &&op_float_round};
|
||||
&&op_float_add, &&op_float_sub, &&op_float_to, &&op_float_round,
|
||||
&&op_float_cmp};
|
||||
AMX_HEADER *hdr;
|
||||
AMX_FUNCSTUB *func;
|
||||
unsigned char *code, *data;
|
||||
cell pri,alt,stk,frm,hea;
|
||||
cell reset_stk, reset_hea, *cip;
|
||||
cell offs, offs2;
|
||||
REAL fnum;
|
||||
REAL fnum, fnum2;
|
||||
ucell codesize;
|
||||
int num,i;
|
||||
|
||||
@ -2658,6 +2661,18 @@ static const void * const amx_opcodelist[] = {
|
||||
fnum = ceil(fnum);
|
||||
pri = (cell)fnum;
|
||||
NEXT(cip);
|
||||
op_float_cmp:
|
||||
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
|
||||
offs2 = *(cell *)(data + (int)stk + sizeof(cell)*2);
|
||||
fnum = amx_ctof(offs);
|
||||
fnum2 = amx_ctof(offs2);
|
||||
if (fnum == fnum2)
|
||||
pri = 0;
|
||||
else if (fnum > fnum2)
|
||||
pri = 1;
|
||||
else
|
||||
pri = -1;
|
||||
NEXT(cip);
|
||||
op_break:
|
||||
if (amx->debug!=NULL) {
|
||||
/* store status */
|
||||
@ -2743,7 +2758,7 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
|
||||
#else
|
||||
OPCODE op;
|
||||
cell offs, offs2;
|
||||
REAL fnum;
|
||||
REAL fnum, fnum2;
|
||||
int num;
|
||||
#endif
|
||||
assert(amx!=NULL);
|
||||
@ -3634,31 +3649,31 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
|
||||
break;
|
||||
case OP_NOP:
|
||||
break;
|
||||
case OP_FLOAT_MUL:
|
||||
case OP_FLOAT_MUL:
|
||||
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
|
||||
offs2 = *(cell *)(data + (int)stk + sizeof(cell)*2);
|
||||
fnum = amx_ctof(offs) * amx_ctof(offs2);
|
||||
pri = amx_ftoc(fnum);
|
||||
break;
|
||||
case OP_FLOAT_ADD:
|
||||
break;
|
||||
case OP_FLOAT_ADD:
|
||||
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
|
||||
offs2 = *(cell *)(data + (int)stk + sizeof(cell)*2);
|
||||
fnum = amx_ctof(offs) + amx_ctof(offs2);
|
||||
pri = amx_ftoc(fnum);
|
||||
break;
|
||||
case OP_FLOAT_SUB:
|
||||
break;
|
||||
case OP_FLOAT_SUB:
|
||||
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
|
||||
offs2 = *(cell *)(data + (int)stk + sizeof(cell)*2);
|
||||
fnum = amx_ctof(offs) - amx_ctof(offs2);
|
||||
pri = amx_ftoc(fnum);
|
||||
break;
|
||||
case OP_FLOAT_DIV:
|
||||
break;
|
||||
case OP_FLOAT_DIV:
|
||||
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
|
||||
offs2 = *(cell *)(data + (int)stk + sizeof(cell)*2);
|
||||
fnum = amx_ctof(offs) / amx_ctof(offs2);
|
||||
pri = amx_ftoc(fnum);
|
||||
break;
|
||||
case OP_FLOAT_TO:
|
||||
break;
|
||||
case OP_FLOAT_TO:
|
||||
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
|
||||
fnum = (float)offs;
|
||||
pri = amx_ftoc(fnum);
|
||||
@ -3669,12 +3684,24 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
|
||||
fnum = amx_ctof(offs);
|
||||
if (!offs2)
|
||||
fnum = (REAL)floor(fnum + 0.5);
|
||||
else if (offs2 == 1)
|
||||
else if (offs2 == 1)
|
||||
fnum = floor(fnum);
|
||||
else
|
||||
fnum = ceil(fnum);
|
||||
pri = (cell)fnum;
|
||||
break;
|
||||
case OP_FLOAT_CMP:
|
||||
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
|
||||
offs2 = *(cell *)(data + (int)stk + sizeof(cell)*2);
|
||||
fnum = amx_ctof(offs);
|
||||
fnum2 = amx_ctof(offs2);
|
||||
if (fnum == fnum2)
|
||||
pri = 0;
|
||||
else if (fnum > fnum2)
|
||||
pri = 1;
|
||||
else
|
||||
pri = -1;
|
||||
break;
|
||||
case OP_BREAK:
|
||||
assert((amx->flags & AMX_FLAG_BROWSE)==0);
|
||||
if (amx->debug!=NULL) {
|
||||
|
@ -1485,7 +1485,19 @@ OP_FLOAT_ROUND:
|
||||
fldcw [esp]
|
||||
pop ebp
|
||||
GO_ON
|
||||
|
||||
|
||||
OP_FLOAT_CMP:
|
||||
add esi, 4
|
||||
fld dword [edi+ecx+8]
|
||||
fld dword [edi+ecx+4]
|
||||
fucompp
|
||||
fnstsw ax
|
||||
sahf
|
||||
cmovz eax, [g_flags+4]
|
||||
cmovg eax, [g_flags+8]
|
||||
cmovl eax, [g_flags+0]
|
||||
GO_ON
|
||||
|
||||
OP_BREAK:
|
||||
mov ebp,amx ; get amx into ebp
|
||||
add esi,4
|
||||
@ -1580,6 +1592,12 @@ Start_DATA
|
||||
|
||||
lodb_and DD 0ffh, 0ffffh, 0, 0ffffffffh
|
||||
|
||||
GLOBAL g_flags
|
||||
g_flags:
|
||||
DD -1
|
||||
DD 0
|
||||
DD 1
|
||||
|
||||
GLOBAL amx_opcodelist
|
||||
GLOBAL _amx_opcodelist
|
||||
amx_opcodelist:
|
||||
@ -1727,3 +1745,4 @@ _amx_opcodelist DD OP_INVALID
|
||||
DD OP_FLOAT_SUB
|
||||
DD OP_FLOAT_TO
|
||||
DD OP_FLOAT_ROUND
|
||||
DD OP_FLOAT_CMP
|
@ -1941,7 +1941,7 @@ OP_FLOAT_TO:
|
||||
CHECKCODESIZE j_float_to
|
||||
|
||||
OP_FLOAT_ROUND:
|
||||
GO_ON j_float_round, OP_INVALID
|
||||
GO_ON j_float_round, OP_FLOAT_CMP
|
||||
j_float_round:
|
||||
;get the float control word
|
||||
push 0
|
||||
@ -1974,6 +1974,19 @@ OP_FLOAT_ROUND:
|
||||
fldcw [esp]
|
||||
pop ebp
|
||||
CHECKCODESIZE j_float_round
|
||||
|
||||
OP_FLOAT_CMP:
|
||||
GO_ON j_float_cmp, OP_INVALID
|
||||
j_float_cmp:
|
||||
fld dword [esi+8]
|
||||
fld dword [esi+4]
|
||||
fucompp
|
||||
fnstsw ax
|
||||
sahf
|
||||
cmovz eax, [g_flagsjit+4]
|
||||
cmovg eax, [g_flagsjit+8]
|
||||
cmovl eax, [g_flagsjit+0]
|
||||
CHECKCODESIZE j_float_cmp
|
||||
|
||||
OP_INVALID: ; break from the compiler with an error code
|
||||
mov eax,AMX_ERR_INVINSTR
|
||||
@ -2403,6 +2416,12 @@ jit_switch DD JIT_OP_SWITCH
|
||||
; The table for the browser/relocator function.
|
||||
;
|
||||
|
||||
global g_flagsjit
|
||||
g_flagsjit:
|
||||
DD -1
|
||||
DD 0
|
||||
DD 1
|
||||
|
||||
global amx_opcodelist_jit, _amx_opcodelist_jit
|
||||
|
||||
amx_opcodelist_jit:
|
||||
@ -2551,5 +2570,6 @@ _amx_opcodelist_jit:
|
||||
DD OP_FLOAT_SUB ; DA
|
||||
DD OP_FLOAT_TO ; DA
|
||||
DD OP_FLOAT_ROUND ; DA
|
||||
DD OP_FLOAT_CMP ; DA
|
||||
|
||||
END
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define OP_FLOAT_SUB 141
|
||||
#define OP_FLOAT_TO 142
|
||||
#define OP_FLOAT_ROUND 143
|
||||
#define OP_FLOAT_CMP 144
|
||||
|
||||
cell op_trans_table[N_Total_FloatOps] =
|
||||
{
|
||||
@ -17,7 +18,8 @@ cell op_trans_table[N_Total_FloatOps] =
|
||||
OP_FLOAT_ADD,
|
||||
OP_FLOAT_SUB,
|
||||
OP_FLOAT_TO,
|
||||
OP_FLOAT_ROUND
|
||||
OP_FLOAT_ROUND,
|
||||
OP_FLOAT_CMP
|
||||
};
|
||||
|
||||
void OnBrowseRelocate(AMX *amx, cell *oplist, cell *cip)
|
||||
@ -87,6 +89,7 @@ void _Setup_Optimizer_Stage2(AMX *amx, cell *oplist, cell *cip)
|
||||
FIND_NATIVE("floatsub", N_Float_Sub);
|
||||
FIND_NATIVE("float", N_Float_To);
|
||||
FIND_NATIVE("floatround", N_Float_Round);
|
||||
FIND_NATIVE("floatcmp", N_Float_Cmp);
|
||||
//we don't do these yet because of radix stuff >:\
|
||||
//FIND_NATIVE("floatsin", N_Float_Sin);
|
||||
//FIND_NATIVE("floatcos", N_Float_Cos);
|
||||
|
@ -11,7 +11,9 @@ enum
|
||||
N_Float_Sub,
|
||||
N_Float_To,
|
||||
N_Float_Round,
|
||||
N_Total_FloatOps
|
||||
N_Float_Cmp,
|
||||
/* ------------ */
|
||||
N_Total_FloatOps,
|
||||
};
|
||||
|
||||
struct optimizer_s
|
||||
|
Loading…
Reference in New Issue
Block a user