-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCPU.h
More file actions
32 lines (25 loc) · 665 Bytes
/
Copy pathCPU.h
File metadata and controls
32 lines (25 loc) · 665 Bytes
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
#ifndef __CPU_H__
#define __CPU_H__
#undef PC
class Stream;
#define O(o, e) case o: e(); break
#define A(o, e, a) case o: e(a); break
#define C(o) case o:
#define D(e) default: e(); break
class CPU: public Checkpointable {
public:
virtual ~CPU() {}
virtual void run(unsigned instructions) =0;
virtual void reset() =0;
virtual void raise(uint8_t level) =0;
virtual char *status(char *buf, size_t n, bool hdr) =0;
virtual void checkpoint(Stream &s) = 0;
virtual void restore(Stream &s) = 0;
inline bool halted() { return _halted; }
protected:
CPU(Memory &mem): _mem(mem), _halted(false) {}
Memory &_mem;
Memory::address PC;
bool _halted;
};
#endif