Virtual 4001 CPU - CPU.h

// -------- CPU.h -----------


#include "Memory.h"
namespace CPU_4001{ class CPU { public:
const byte c_ReservedAddress; const byte c_BaseAddress; const byte c_AddressCeiling;
byte m_ProgramCounter; byte m_Register0; byte m_Register1; bool m_OverflowError; bool m_UnderflowError; bool m_SignedMode; bool m_Halt;
Memory* m_TheMemory;
const byte Fetch();
void Decode(const byte& p_OpCode);
void Halt();
void Add();
void Beep();
void Store();
void Print();
CPU(Memory* p_TheMemory);
void Reset();
void Run();


  1. thank you, great, one question: do you really need to capitalize on every m_NewWordInCapsLock? coz waste of time.

    1. This approach to naming and typing is called "Camel Case", and it's purpose is not to save you time now, it's to save you time in a week, or a month, or a year. Because though you're right it takes slightly longer to type, as I have to hold the shift key every now and then, but to read it back makes it so much more easy to read.

      And I've made sure variables, be they local, member, global or parameters, have meaningful names, and I can quickly with my naming convention check their scope.

      This is C++, it's all about maintainability, under the hood the compiler strips everything down to bare bones, so in the actual code you should always aim to readability, to optimize maintainability.

      Also, if you're "slowed" by using the shift key, your touch typing technique needs work :)