From ae9bc91713f86cfc16e801ca33654a47082ddb2b Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 23 Oct 2023 00:09:12 +0100 Subject: Added and implemented OP_PRINT* Here is where we may have differing interpretations of what the bits in the data pile may actually mean. This in particular refers to printing the signed or unsigned versions of the bits given. Also, interpreting some byte as a character or just a raw number. --- src/inst.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/inst.h') diff --git a/src/inst.h b/src/inst.h index e10d744..b9e0e9b 100644 --- a/src/inst.h +++ b/src/inst.h @@ -70,6 +70,14 @@ typedef enum OP_PLUS_HWORD, OP_PLUS_WORD, + // Simple I/O + OP_PRINT_CHAR, + OP_PRINT_BYTE, + OP_PRINT_INT, + OP_PRINT_HWORD, + OP_PRINT_LONG, + OP_PRINT_WORD, + // Program control flow OP_JUMP_ABS, OP_JUMP_STACK, @@ -127,12 +135,11 @@ inst_t *insts_read_bytecode_file(FILE *, size_t *); #define INST_DUP(TYPE, OP) \ ((inst_t){.opcode = OP_DUP_##TYPE, .operand = DWORD(OP)}) -#define INST_NOT(TYPE) ((inst_t){.opcode = OP_NOT_##TYPE}) -#define INST_OR(TYPE) ((inst_t){.opcode = OP_OR_##TYPE}) -#define INST_AND(TYPE) ((inst_t){.opcode = OP_AND_##TYPE}) -#define INST_XOR(TYPE) ((inst_t){.opcode = OP_XOR_##TYPE}) -#define INST_EQ(TYPE) ((inst_t){.opcode = OP_EQ_##TYPE}) - +#define INST_NOT(TYPE) ((inst_t){.opcode = OP_NOT_##TYPE}) +#define INST_OR(TYPE) ((inst_t){.opcode = OP_OR_##TYPE}) +#define INST_AND(TYPE) ((inst_t){.opcode = OP_AND_##TYPE}) +#define INST_XOR(TYPE) ((inst_t){.opcode = OP_XOR_##TYPE}) +#define INST_EQ(TYPE) ((inst_t){.opcode = OP_EQ_##TYPE}) #define INST_PLUS(TYPE) ((inst_t){.opcode = OP_PLUS_##TYPE}) #define INST_JUMP_ABS(OP) \ @@ -140,4 +147,5 @@ inst_t *insts_read_bytecode_file(FILE *, size_t *); #define INST_JUMP_STACK ((inst_t){.opcode = OP_JUMP_STACK}) #define INST_JUMP_REGISTER ((inst_t){.opcode = OP_JUMP_REGISTER}) +#define INST_PRINT(TYPE) ((inst_t){.opcode = OP_PRINT_##TYPE}) #endif -- cgit v1.2.3-13-gbd6f