aboutsummaryrefslogtreecommitdiff
path: root/lib/inst.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-01 14:23:48 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-01 14:23:48 +0000
commit727081f99a5065787dd3d035f92ef9f502f3622c (patch)
treee5989948e5a8d46c78345e09d5f8b80f1600efda /lib/inst.c
parent90fb9816b495167c66f40284b66a9d4da22ae769 (diff)
downloadovm-727081f99a5065787dd3d035f92ef9f502f3622c.tar.gz
ovm-727081f99a5065787dd3d035f92ef9f502f3622c.tar.bz2
ovm-727081f99a5065787dd3d035f92ef9f502f3622c.zip
Removed OP_EQ signed versions as they're useless
A negative number under 2s complement can never be equal to its positive as the top bit *must* be on. If two numbers are equivalent bit-by-bit then they are equal for both signed and unsigned numbers.
Diffstat (limited to 'lib/inst.c')
-rw-r--r--lib/inst.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/inst.c b/lib/inst.c
index 5be2438..98bbc98 100644
--- a/lib/inst.c
+++ b/lib/inst.c
@@ -108,18 +108,9 @@ const char *opcode_as_cstr(opcode_t code)
case OP_EQ_BYTE:
return "EQ_BYTE";
break;
- case OP_EQ_CHAR:
- return "EQ_CHAR";
- break;
- case OP_EQ_INT:
- return "EQ_INT";
- break;
case OP_EQ_HWORD:
return "EQ_HWORD";
break;
- case OP_EQ_LONG:
- return "EQ_LONG";
- break;
case OP_EQ_WORD:
return "EQ_WORD";
break;
@@ -270,7 +261,7 @@ void data_print(data_t datum, data_type_t type, FILE *fp)
void inst_print(inst_t instruction, FILE *fp)
{
- static_assert(NUMBER_OF_OPCODES == 73, "inst_bytecode_size: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 70, "inst_bytecode_size: Out of date");
fprintf(fp, "%s(", opcode_as_cstr(instruction.opcode));
if (OPCODE_IS_TYPE(instruction.opcode, OP_PUSH))
{
@@ -300,7 +291,7 @@ void inst_print(inst_t instruction, FILE *fp)
size_t inst_bytecode_size(inst_t inst)
{
- static_assert(NUMBER_OF_OPCODES == 73, "inst_bytecode_size: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 70, "inst_bytecode_size: Out of date");
size_t size = 1; // for opcode
if (OPCODE_IS_TYPE(inst.opcode, OP_PUSH))
{
@@ -324,7 +315,7 @@ size_t inst_bytecode_size(inst_t inst)
void inst_write_bytecode(inst_t inst, darr_t *darr)
{
- static_assert(NUMBER_OF_OPCODES == 73, "inst_write_bytecode: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 70, "inst_write_bytecode: Out of date");
// Append opcode
darr_append_byte(darr, inst.opcode);
// Then append 0 or more operands
@@ -398,7 +389,7 @@ data_t read_type_from_darr(darr_t *darr, data_type_t type)
inst_t inst_read_bytecode(darr_t *darr)
{
- static_assert(NUMBER_OF_OPCODES == 73, "inst_read_bytecode: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 70, "inst_read_bytecode: Out of date");
if (darr->used >= darr->available)
return (inst_t){0};
inst_t inst = {0};