From 497cd7ce3b5c09b9fce9f624a7015e65b18c2953 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Thu, 30 May 2024 15:21:24 +0100 Subject: [PATCH] Add instruction type classification to decode, w/ T --- src/decode.c | 19 +++++++++++++++++++ src/decode.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/src/decode.c b/src/decode.c index a1f7819..77c47b7 100644 --- a/src/decode.c +++ b/src/decode.c @@ -21,4 +21,23 @@ a64inst_instruction *decode(word wrd) { fprintf(stderr, "Ran out of memory while attempting to decode an instruction!\n"); exit(1); } + + word DPImmFlag = getBits(wrd, DATA_PROCESSING_DPIMM_LSB, DATA_PROCESSING_DPIMM_MSB); + if (wrd == HALT_WORD) { + inst->type = a64inst_Halt; + + } else if (DPImmFlag == 0) { + inst->type = a64inst_DPImmediate; + + }else if (DPImmFlag == 1) { + inst->type = a64inst_Branch; + + } else if (getBits(wrd, DATA_PROCESSING_DPReg_LSB, DATA_PROCESSING_DPReg_MSB) == 1) { + inst->type = a64inst_DPRegister; + + } else { + // Load and Store, or unknown + } + + } diff --git a/src/decode.h b/src/decode.h index a76bcdd..c24c235 100644 --- a/src/decode.h +++ b/src/decode.h @@ -2,5 +2,12 @@ #include "a64instruction.h" #define BYTE_BITS 8 +#define HALT_WORD 0x8a000000 + +#define DATA_PROCESSING_DPIMM_LSB 26 +#define DATA_PROCESSING_DPIMM_MSB 29 + +#define DATA_PROCESSING_DPReg_LSB 25 +#define DATA_PROCESSING_DPReg_MSB 26 a64inst_instruction *decode(word w); \ No newline at end of file