-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCPU.h
45 lines (33 loc) · 842 Bytes
/
CPU.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef cpu_h
#define cpu_h
// emulates the KENBAK-1 "cpu"
#define REG_A_IDX 000
#define REG_B_IDX 001
#define REG_X_IDX 002
#define REG_P_IDX 003
#define REG_OUTPUT_IDX 0200
#define REG_FLAGS_A_IDX 0201
#define REG_FLAGS_B_IDX 0202
#define REG_FLAGS_X_IDX 0203
#define REG_INPUT_IDX 0377
class CPU
{
public:
CPU(void);
virtual void Init();
virtual bool Step();
byte Read(byte Addr);
void Write(byte Addr, byte Value);
void ClearAllMemory();
virtual bool OnNOOPExtension(byte Op);
byte* Memory();
static CPU* cpu;
private:
byte GetBitField(byte Byte, int BitNum, int NumBits);
byte* GetAddr(byte* pByte, byte Mode);
byte* GetNextByte();
bool Execute(byte Instruction);
byte m_Memory[256];
byte m_InstructionBytes = 0;
};
#endif