-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopcode.h
More file actions
55 lines (42 loc) · 1.07 KB
/
opcode.h
File metadata and controls
55 lines (42 loc) · 1.07 KB
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
#ifndef OPCODE_H
#define OPCODE_H
// all branch targets are 2 bytes absolute reference, little endian
// T -> Test for literal char
// U -> Test for not literal char
// A -> test for Alpha char
// N -> test for Numeric char
// J -> jump to subroutine
// R -> Return from subroutine
// S -> Set flag
// B -> Branch unconditionally
// I -> branch If
// E -> branch if Error
// L -> copy Literal
// C -> Copy input char to output buffer
// H -> copy hex representation of input char to output buffer
// G -> Generate label
// F -> Fix left (for labels)
// O -> Output buffer
// D -> Delete buffer
#define OPCODES \
X(T, "TST") X(U, "UNTST") X(A, "ALPH") X(N, "NUM") \
X(J, "JSR") X(R, "RTS") X(S, "SET") \
X(B, "BRA") X(I, "BIF") X(E, "BERR") X(L, "LIT") \
X(C, "CPY") X(H, "HEXCPY") \
X(G, "GENLBL") X(F, "LBL") X(O, "OUT") X(D, "DEL")
typedef enum {
#define X(nm,lnm) nm,
OPCODES
#undef X
} opcode;
char* opcode_names[] = {
#define X(nm,lnm) #nm,
OPCODES
#undef X
};
char* opcode_long_names[] = {
#define X(nm,lnm) lnm,
OPCODES
#undef X
};
#endif