MIXAL
include
instructions.h
Go to the documentation of this file.
1
#ifndef INCLUDE_INSTRUCTIONS_H_
2
#define INCLUDE_INSTRUCTIONS_H_
3
4
#include <cstdint>
5
#include <string>
6
12
namespace
mixal {
13
15
class
Instructions
{
16
public
:
17
enum
Code {
18
INVALID = -1,
19
NOP = 0,
// no operation
20
ADD = 1,
// add
21
FADD = 1,
// float add (6)
22
SUB = 2,
// subtract
23
FSUB = 2,
// float subtract (6)
24
MUL = 3,
// multiply
25
FMUL = 3,
// float multiply (6)
26
DIV = 4,
// divide
27
FDIV = 4,
// float divide (6)
28
NUM = 5,
// convert to numeric (0)
29
CHAR = 5,
// convert to characters (1)
30
HLT = 5,
// halt (2)
31
SLA = 6,
// shift left A (0)
32
SRA = 6,
// shift right A (1)
33
SLAX = 6,
// shift left AX (2)
34
SRAX = 6,
// shift right AX (3)
35
SLC = 6,
// shift left AX circularly (4)
36
SRC = 6,
// shift right AX circularly (5)
37
MOVE = 7,
// move
38
LDA = 8,
// load A
39
LD1 = 9,
// load I1
40
LD2 = 10,
// load I2
41
LD3 = 11,
// load I3
42
LD4 = 12,
// load I4
43
LD5 = 13,
// load I5
44
LD6 = 14,
// load I6
45
LDX = 15,
// load X
46
LDAN = 16,
// load A negative
47
LD1N = 17,
// load I1 negative
48
LD2N = 18,
// load I2 negative
49
LD3N = 19,
// load I3 negative
50
LD4N = 20,
// load I4 negative
51
LD5N = 21,
// load I5 negative
52
LD6N = 22,
// load I6 negative
53
LDXN = 23,
// load X
54
STA = 24,
// store A
55
ST1 = 25,
// store I1
56
ST2 = 26,
// store I2
57
ST3 = 27,
// store I3
58
ST4 = 28,
// store I4
59
ST5 = 29,
// store I5
60
ST6 = 30,
// store I6
61
STX = 31,
// store X
62
STJ = 32,
// store J
63
STZ = 33,
// store zero
64
JBUS = 34,
// jump busy
65
IOC = 35,
// input-output control
66
IN = 36,
// input
67
OUT = 37,
// output
68
JRED = 38,
// jump ready
69
JMP = 39,
// jump (0)
70
JSJ = 39,
// jump, save J (1)
71
JOV = 39,
// jump on overflow (2)
72
JNOV = 39,
// jump on no overflow (3)
73
JL = 39,
// jump on less (4)
74
JE = 39,
// jump on equal (5)
75
JG = 39,
// jump on greater (6)
76
JGE = 39,
// jump on greater-or-equal (7)
77
JNE = 39,
// jump on unequal (8)
78
JLE = 39,
// jump on less-or-equal (9)
79
JAN = 40,
// jump A negative (0)
80
JAZ = 40,
// jump A zero (1)
81
JAP = 40,
// jump A positive (2)
82
JANN = 40,
// jump A nonnegative (3)
83
JANZ = 40,
// jump A nonzero (4)
84
JANP = 40,
// jump A nonpositive (5)
85
J1N = 41,
// jump I1 negative (0)
86
J1Z = 41,
// jump I1 zero (1)
87
J1P = 41,
// jump I1 positive (2)
88
J1NN = 41,
// jump I1 nonnegative (3)
89
J1NZ = 41,
// jump I1 nonzero (4)
90
J1NP = 41,
// jump I1 nonpositive (5)
91
J2N = 42,
// jump I2 negative (0)
92
J2Z = 42,
// jump I2 zero (1)
93
J2P = 42,
// jump I2 positive (2)
94
J2NN = 42,
// jump I2 nonnegative (3)
95
J2NZ = 42,
// jump I2 nonzero (4)
96
J2NP = 42,
// jump I2 nonpositive (5)
97
J3N = 43,
// jump I3 negative (0)
98
J3Z = 43,
// jump I3 zero (1)
99
J3P = 43,
// jump I3 positive (2)
100
J3NN = 43,
// jump I3 nonnegative (3)
101
J3NZ = 43,
// jump I3 nonzero (4)
102
J3NP = 43,
// jump I3 nonpositive (5)
103
J4N = 44,
// jump I4 negative (0)
104
J4Z = 44,
// jump I4 zero (1)
105
J4P = 44,
// jump I4 positive (2)
106
J4NN = 44,
// jump I4 nonnegative (3)
107
J4NZ = 44,
// jump I4 nonzero (4)
108
J4NP = 44,
// jump I4 nonpositive (5)
109
J5N = 45,
// jump I5 negative (0)
110
J5Z = 45,
// jump I5 zero (1)
111
J5P = 45,
// jump I5 positive (2)
112
J5NN = 45,
// jump I5 nonnegative (3)
113
J5NZ = 45,
// jump I5 nonzero (4)
114
J5NP = 45,
// jump I5 nonpositive (5)
115
J6N = 46,
// jump I6 negative (0)
116
J6Z = 46,
// jump I6 zero (1)
117
J6P = 46,
// jump I6 positive (2)
118
J6NN = 46,
// jump I6 nonnegative (3)
119
J6NZ = 46,
// jump I6 nonzero (4)
120
J6NP = 46,
// jump I6 nonpositive (5)
121
JXN = 47,
// jump X negative (0)
122
JXZ = 47,
// jump X zero (1)
123
JXP = 47,
// jump X positive (2)
124
JXNN = 47,
// jump X nonnegative (3)
125
JXNZ = 47,
// jump X nonzero (4)
126
JXNP = 47,
// jump X nonpositive (5)
127
INCA = 48,
// increase A (0)
128
DECA = 48,
// decrease A (1)
129
ENTA = 48,
// enter A (2)
130
ENNA = 48,
// enter negative A (3)
131
INC1 = 49,
// increase I1 (0)
132
DEC1 = 49,
// decrease I1 (1)
133
ENT1 = 49,
// enter I1 (2)
134
ENN1 = 49,
// enter negative I1 (3)
135
INC2 = 50,
// increase I2 (0)
136
DEC2 = 50,
// decrease I2 (1)
137
ENT2 = 50,
// enter I2 (2)
138
ENN2 = 50,
// enter negative I2 (3)
139
INC3 = 51,
// increase I3 (0)
140
DEC3 = 51,
// decrease I3 (1)
141
ENT3 = 51,
// enter I3 (2)
142
ENN3 = 51,
// enter negative I3 (3)
143
INC4 = 52,
// increase I4 (0)
144
DEC4 = 52,
// decrease I4 (1)
145
ENT4 = 52,
// enter I4 (2)
146
ENN4 = 52,
// enter negative I4 (3)
147
INC5 = 53,
// increase I5 (0)
148
DEC5 = 53,
// decrease I5 (1)
149
ENT5 = 53,
// enter I5 (2)
150
ENN5 = 53,
// enter negative I5 (3)
151
INC6 = 54,
// increase I6 (0)
152
DEC6 = 54,
// decrease I6 (1)
153
ENT6 = 54,
// enter I6 (2)
154
ENN6 = 54,
// enter negative I6 (3)
155
INCX = 55,
// increase X (0)
156
DECX = 55,
// decrease X (1)
157
ENTX = 55,
// enter X (2)
158
ENNX = 55,
// enter negative X (3)
159
CMPA = 56,
// compare A
160
FCMP = 56,
// float compare A (6)
161
CMP1 = 57,
// compare I1
162
CMP2 = 58,
// compare I2
163
CMP3 = 59,
// compare I3
164
CMP4 = 60,
// compare I4
165
CMP5 = 61,
// compare I5
166
CMP6 = 62,
// compare I6
167
CMPX = 63,
// compare IX
168
LAST = 63,
// last operation
169
PSEUDO = 100,
// pseudo-operation: begin index
170
EQU = 100,
// pseudo-operation: equivalent
171
ORIG = 101,
// pseudo-operation: originate
172
CON = 102,
// pseudo-operation: constant
173
ALF = 103,
// pseudo-operation: alphabeta
174
END = 104,
// pseudo-operation: end
175
};
176
178
static
bool
hasArguments
(Instructions::Code code);
180
static
Instructions::Code
getInstructionCode
(
const
std::string& name);
182
static
int
getDefaultField
(
const
std::string& name);
184
static
int
getCost
(Instructions::Code code, uint8_t field = 0);
185
};
186
187
};
// namespace mixal
188
189
190
#endif // INCLUDE_INSTRUCTIONS_H_
mixal::Instructions
Definition:
instructions.h:15
mixal::Instructions::getDefaultField
static int getDefaultField(const std::string &name)
Definition:
instructions.cpp:1222
mixal::Instructions::getCost
static int getCost(Instructions::Code code, uint8_t field=0)
Definition:
instructions.cpp:2045
mixal::Instructions::hasArguments
static bool hasArguments(Instructions::Code code)
Definition:
instructions.cpp:5
mixal::Instructions::getInstructionCode
static Instructions::Code getInstructionCode(const std::string &name)
Definition:
instructions.cpp:9
Generated by
1.8.20