From 74bf3ed910c596a5d70f29c6561262f15b87f989 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Thu, 30 May 2024 15:02:00 +0100 Subject: [PATCH] Add emulate constants and machine state, w/ T --- src/decode.c | 2 -- src/emulator.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/emulator.h diff --git a/src/decode.c b/src/decode.c index f258122..a1f7819 100644 --- a/src/decode.c +++ b/src/decode.c @@ -3,8 +3,6 @@ #include #include "decode.h" -#define BYTE_BITS 8 - // Retrieve the bits between positions 'lsb' (inclusive) and 'msb' (exclusive) from a given word // as a new zero-extended word. static word getBits(word wrd, uint8_t lsb, uint8_t msb) { diff --git a/src/emulator.h b/src/emulator.h new file mode 100644 index 0000000..b4ea4bf --- /dev/null +++ b/src/emulator.h @@ -0,0 +1,24 @@ +#include "global.h" + +/************************************ + * DEFINITIONS + ************************************/ + #define BYTE_BITS 8 + +/************************************ + * STRUCTS + ************************************/ + +typedef struct { + bool Negative; + bool Zero; + bool Carry; + bool Overflow; +} PState; + +typedef struct { + word registers[REGISTER_COUNT]; + word pc; + byte memory[MEMORY_SIZE]; + PState conditionCodes; +} Machine; \ No newline at end of file