blob: 69e9a8a871085dce02f4cc1b776bd45b7c4a3f7c (
plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#define BEGIN \
do{ \
chip8* c8 = usrdat; \
assert(c8);
#define END }while(0)
#define X_C8_ILL \
BEGIN \
\
c8->running = false; \
report(ERR, "Illegal instruction (%04X) @ %04X\n", instr, offset); \
END
#define X_C8_CLS X_C8_ILL
#define X_C8_RET X_C8_ILL
#define X_C8_SYS X_C8_ILL
#define X_C8_JP \
BEGIN \
c8->pc = nnn - 2; \
END
#define X_C8_CALL X_C8_ILL
#define X_C8_LDI X_C8_ILL
#define X_C8_JPV X_C8_ILL
#define X_C8_SEB \
BEGIN \
if(c8->V[x] == kk) c8->pc += 2; \
END
#define X_C8_SNEB X_C8_ILL
#define X_C8_LD \
BEGIN \
c8->V[x] = kk; \
END
#define X_C8_ADDB \
BEGIN \
int tmp = (int)c8->V[x] + (int)kk; \
c8->V[x] = tmp & 0xFF; \
END
#define X_C8_RND X_C8_ILL
#define X_C8_SKP X_C8_ILL
#define X_C8_SKNP X_C8_ILL
#define X_C8_MVDT X_C8_ILL
#define X_C8_LDK X_C8_ILL
#define X_C8_LDDT X_C8_ILL
#define X_C8_LDST X_C8_ILL
#define X_C8_ADDI X_C8_ILL
#define X_C8_HEX X_C8_ILL
#define X_C8_BCD X_C8_ILL
#define X_C8_SAVE X_C8_ILL
#define X_C8_RESTORE X_C8_ILL
#define X_C8_SE X_C8_ILL
#define X_C8_MOVE X_C8_ILL
#define X_C8_OR X_C8_ILL
#define X_C8_AND X_C8_ILL
#define X_C8_XOR X_C8_ILL
#define X_C8_ADD \
BEGIN \
int tmp = (int)c8->V[x] + (int)c8->V[y]; \
c8->V[0xf] = (tmp > 255); \
c8->V[x] = tmp & 0xFF; \
END
#define X_C8_SUB X_C8_ILL
#define X_C8_SHR X_C8_ILL
#define X_C8_SUBN X_C8_ILL
#define X_C8_SHL X_C8_ILL
#define X_C8_SNE X_C8_ILL
#define X_C8_DRW X_C8_ILL
c8_decode_generate(exec)
#undef BEGIN
#undef END
#include "undef.c"
|