b = (short)b;
if (a >= prog->progs_numglobals || b + i < 0 || b + i >= prog->progs_numstatements)
prog->error_cmd("PRVM_LoadProgs: out of bounds IF/IFNOT (statement %d) in %s", i, prog->name);
- //To be rewritten
prog->statements[i].ins = INS_IF;
prog->statements[i].operand[0] = remapglobal(a);
prog->statements[i].operand[1] = op - OP_IF;
prog->statements[i].operand[2] = remapglobal(c);
prog->statements[i].jumpabsolute = -1;
break;
+ case OP_GT:
+ case OP_LT:
+ case OP_GE:
+ case OP_LE:
+ //TODO: rewrite all float comparasions in one instruction
+ if (a >= prog->progs_numglobals || b >= prog->progs_numglobals || c >= prog->progs_numglobals)
+ prog->error_cmd("PRVM_LoadProgs: out of bounds global index (statement %d)", i);
+ if(op == OP_LT)
+ d = 1;
+ else if (op == OP_GT)
+ d = 3;
+ prog->statements[i].ins = op - OP_LE + INS_LE - d;
+ prog->statements[i].operand[0] = remapglobal(a);
+ prog->statements[i].operand[1] = remapglobal(b);
+ prog->statements[i].operand[2] = remapglobal(c);
+ prog->statements[i].jumpabsolute = !!d;
+ break;
//regular
case OP_BITAND:
case OP_BITOR:
d += 4;//Skip loads
case OP_LOAD_V://LOAD_VECTOR
case OP_LOAD_F://LOAD_SCALAR
- case OP_GE:
- case OP_LE:
- case OP_GT:
- case OP_LT:
+ d += 2;//Skip LT, GT
case OP_NE_F:
case OP_NE_V:
case OP_NE_S:
&&handle_INS_DONE,
&&handle_INS_MUL_F,
&&handle_INS_MUL_V,
- #if 0
- NULL,
- #endif
&&handle_INS_MUL_VF,
&&handle_INS_DIV_F,
&&handle_INS_ADD_F,
&&handle_INS_LE,
&&handle_INS_GE,
- &&handle_INS_LT,
- &&handle_INS_GT,
&&handle_INS_LOAD_SCALAR,
&&handle_INS_LOAD_VECTOR,
OPC->_float = (prvm_int_t)OPA->_float | (prvm_int_t)OPB->_float;
DISPATCH_OPCODE();
HANDLE_OPCODE(INS_GE):
- OPC->_float = OPA->_float >= OPB->_float;
+ OPC->_float = st->jumpabsolute ^ (OPA->_float >= OPB->_float);
DISPATCH_OPCODE();
HANDLE_OPCODE(INS_LE):
- OPC->_float = OPA->_float <= OPB->_float;
- DISPATCH_OPCODE();
- HANDLE_OPCODE(INS_GT):
- OPC->_float = OPA->_float > OPB->_float;
- DISPATCH_OPCODE();
- HANDLE_OPCODE(INS_LT):
- OPC->_float = OPA->_float < OPB->_float;
+ OPC->_float = st->jumpabsolute ^ (OPA->_float <= OPB->_float);
DISPATCH_OPCODE();
HANDLE_OPCODE(INS_AND):
OPC->_float = FLOAT_IS_TRUE_FOR_INT(OPA->_int) && FLOAT_IS_TRUE_FOR_INT(OPB->_int); // TODO change this back to float, and add AND_I to be used by fteqcc for anything not a float