From 13790e0cdaf3f4a40f104be9e5d2a27fed6818f1 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 25 Apr 2024 02:53:55 +0530 Subject: [PATCH] Split OPCODE_IS_TYPE -> SIGNED|UNSIGNED Due to reordering I need to have two macros for checking if an opcode is of a type. If the type is signed then the upper bound must be OP__LONG whereas if it is unsigned then the upper bound must be OP__WORD. --- lib/inst.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/inst.h b/lib/inst.h index 239a968..10a2702 100644 --- a/lib/inst.h +++ b/lib/inst.h @@ -21,13 +21,13 @@ const char *opcode_as_cstr(opcode_t); -#define OPCODE_IS_TYPE(OPCODE, OP_TYPE) \ +#define UNSIGNED_OPCODE_IS_TYPE(OPCODE, OP_TYPE) \ (((OPCODE) >= OP_TYPE##_BYTE) && ((OPCODE) <= OP_TYPE##_WORD)) -#define OPCODE_DATA_TYPE(OPCODE, OP_TYPE) \ - ((OPCODE) == OP_TYPE##_BYTE ? DATA_TYPE_BYTE \ - : ((OPCODE) == OP_TYPE##_HWORD) ? DATA_TYPE_HWORD \ - : DATA_TYPE_WORD) +#define SIGNED_OPCODE_IS_TYPE(OPCODE, OP_TYPE) \ + (((OPCODE) >= OP_TYPE##_BYTE) && ((OPCODE) <= OP_TYPE##_LONG)) + +#define OPCODE_DATA_TYPE(OPCODE, OP_TYPE) (OPCODE - OP_TYPE##_BYTE) // OPCODE_DATA_TYPE: opcode_t -> data_type_t. data_type_t acts as // a map between types and their offsets from the first type of