aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/inst.c20
-rw-r--r--lib/inst.h3
2 files changed, 7 insertions, 16 deletions
diff --git a/lib/inst.c b/lib/inst.c
index 85fb23b..da951fe 100644
--- a/lib/inst.c
+++ b/lib/inst.c
@@ -193,8 +193,6 @@ const char *opcode_as_cstr(opcode_t code)
return "JUMP_ABS";
case OP_JUMP_STACK:
return "JUMP_STACK";
- case OP_JUMP_REGISTER:
- return "JUMP_REGISTER";
case OP_JUMP_IF_BYTE:
return "JUMP_IF_BYTE";
case OP_JUMP_IF_HWORD:
@@ -241,7 +239,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 == 96, "inst_bytecode_size: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 95, "inst_bytecode_size: Out of date");
fprintf(fp, "%s(", opcode_as_cstr(instruction.opcode));
if (OPCODE_IS_TYPE(instruction.opcode, OP_PUSH))
{
@@ -250,8 +248,7 @@ void inst_print(inst_t instruction, FILE *fp)
data_print(instruction.operand, type, fp);
}
else if (OPCODE_IS_TYPE(instruction.opcode, OP_PUSH_REGISTER) ||
- OPCODE_IS_TYPE(instruction.opcode, OP_MOV) ||
- instruction.opcode == OP_JUMP_REGISTER)
+ OPCODE_IS_TYPE(instruction.opcode, OP_MOV))
{
fprintf(fp, "reg=0x");
data_print(instruction.operand, DATA_TYPE_BYTE, fp);
@@ -274,7 +271,7 @@ void inst_print(inst_t instruction, FILE *fp)
size_t inst_bytecode_size(inst_t inst)
{
- static_assert(NUMBER_OF_OPCODES == 96, "inst_bytecode_size: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 95, "inst_bytecode_size: Out of date");
size_t size = 1; // for opcode
if (OPCODE_IS_TYPE(inst.opcode, OP_PUSH))
{
@@ -291,7 +288,6 @@ size_t inst_bytecode_size(inst_t inst)
OPCODE_IS_TYPE(inst.opcode, OP_MALLOC) ||
OPCODE_IS_TYPE(inst.opcode, OP_MSET) ||
OPCODE_IS_TYPE(inst.opcode, OP_MGET) || inst.opcode == OP_JUMP_ABS ||
- inst.opcode == OP_JUMP_REGISTER ||
OPCODE_IS_TYPE(inst.opcode, OP_JUMP_IF))
size += WORD_SIZE;
return size;
@@ -299,7 +295,7 @@ size_t inst_bytecode_size(inst_t inst)
void inst_write_bytecode(inst_t inst, darr_t *darr)
{
- static_assert(NUMBER_OF_OPCODES == 96, "inst_write_bytecode: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 95, "inst_write_bytecode: Out of date");
// Append opcode
darr_append_byte(darr, inst.opcode);
// Then append 0 or more operands
@@ -311,8 +307,7 @@ void inst_write_bytecode(inst_t inst, darr_t *darr)
OPCODE_IS_TYPE(inst.opcode, OP_DUP) ||
OPCODE_IS_TYPE(inst.opcode, OP_MALLOC) ||
OPCODE_IS_TYPE(inst.opcode, OP_MSET) ||
- OPCODE_IS_TYPE(inst.opcode, OP_MGET) ||
- inst.opcode == OP_JUMP_REGISTER || inst.opcode == OP_JUMP_ABS ||
+ OPCODE_IS_TYPE(inst.opcode, OP_MGET) || inst.opcode == OP_JUMP_ABS ||
OPCODE_IS_TYPE(inst.opcode, OP_JUMP_IF))
to_append = DATA_TYPE_WORD;
@@ -375,7 +370,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 == 96, "inst_read_bytecode: Out of date");
+ static_assert(NUMBER_OF_OPCODES == 95, "inst_read_bytecode: Out of date");
if (darr->used >= darr->available)
return (inst_t){0};
inst_t inst = {0};
@@ -387,8 +382,7 @@ inst_t inst_read_bytecode(darr_t *darr)
inst.operand = read_type_from_darr(darr, (data_type_t)opcode);
// Read register (as a byte)
else if (OPCODE_IS_TYPE(opcode, OP_PUSH_REGISTER) ||
- OPCODE_IS_TYPE(opcode, OP_MOV) || opcode == OP_JUMP_REGISTER ||
- OPCODE_IS_TYPE(opcode, OP_DUP) ||
+ OPCODE_IS_TYPE(opcode, OP_MOV) || OPCODE_IS_TYPE(opcode, OP_DUP) ||
OPCODE_IS_TYPE(opcode, OP_MALLOC) ||
OPCODE_IS_TYPE(opcode, OP_MSET) || OPCODE_IS_TYPE(opcode, OP_MGET) ||
opcode == OP_JUMP_ABS || OPCODE_IS_TYPE(opcode, OP_JUMP_IF))
diff --git a/lib/inst.h b/lib/inst.h
index 63b1669..55c062f 100644
--- a/lib/inst.h
+++ b/lib/inst.h
@@ -145,7 +145,6 @@ typedef enum
// Program control flow
OP_JUMP_ABS,
OP_JUMP_STACK,
- OP_JUMP_REGISTER,
OP_JUMP_IF_BYTE,
OP_JUMP_IF_HWORD,
OP_JUMP_IF_WORD,
@@ -230,8 +229,6 @@ inst_t *insts_read_bytecode_file(FILE *, size_t *);
#define INST_JUMP_ABS(OP) \
((inst_t){.opcode = OP_JUMP_ABS, .operand = DWORD(OP)})
#define INST_JUMP_STACK ((inst_t){.opcode = OP_JUMP_STACK})
-#define INST_JUMP_REGISTER(OP) \
- ((inst_t){.opcode = OP_JUMP_REGISTER, .operand = DWORD(OP)})
#define INST_JUMP_IF(TYPE, OP) \
((inst_t){.opcode = OP_JUMP_IF_##TYPE, .operand = DWORD(OP)})