From 51a873e58d1f9c7da95cd4f835323ee8156ad39f Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 22 Nov 2019 00:44:58 +1000 Subject: [PATCH] CPU: Expand register file to include hi/lo/pc/npc --- src/core/cpu_types.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/cpu_types.h b/src/core/cpu_types.h index c152e6dfb..8a0b716a2 100644 --- a/src/core/cpu_types.h +++ b/src/core/cpu_types.h @@ -50,6 +50,13 @@ enum class Reg : u8 sp, fp, ra, + + // not accessible to instructions + hi, + lo, + pc, + npc, + count }; @@ -219,7 +226,7 @@ struct Registers { union { - u32 r[32]; + u32 r[static_cast(Reg::count)]; struct { @@ -255,13 +262,14 @@ struct Registers u32 sp; // r29 u32 fp; // r30 u32 ra; // r31 + + // not accessible to instructions + u32 hi; + u32 lo; + u32 pc; // at execution time: the address of the next instruction to execute (already fetched) + u32 npc; // at execution time: the address of the next instruction to fetch }; }; - - u32 hi; - u32 lo; - u32 pc; // at execution time: the address of the next instruction to execute (already fetched) - u32 npc; // at execution time: the address of the next instruction to fetch }; enum class Cop0Reg : u8