Browse code

Add source code of the assembler compiler

Pawel Jablonski authored on 14/12/2022 19:04:16
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,50 @@
1
+/*
2
+ * Author: Pawel Jablonski
3
+ * E-mail: pj@xirx.net
4
+ * WWW: xirx.net
5
+ * GIT: git.xirx.net
6
+ *
7
+ * License: You can use this code however you like
8
+ * but leave information about the original author.
9
+ * Code is free for non-commercial and commercial use.
10
+ */
11
+
12
+#ifndef INSTRUCTION_H
13
+#define INSTRUCTION_H
14
+
15
+#include <QString>
16
+#include <QList>
17
+
18
+//! This class contains a one description of the CPU instruction
19
+class Instruction
20
+{
21
+	public:
22
+		//! Definitions of the instruction argument types
23
+		enum class Arg
24
+		{
25
+			None, //!< No argument
26
+			ABXY, //!< Main and auxiliary registers
27
+			AB, //!< Only main registers
28
+			Val256, //!< 8 bit unsigned value
29
+			Addr //!< 16 bit unsigned address
30
+		};
31
+
32
+		Instruction(const QString &name, unsigned char opcode, Arg arg0 = Arg::None, Arg arg1 = Arg::None, Arg arg2 = Arg::None, unsigned char opcodeSecond = 0, Arg arg0Second = Arg::None, Arg arg1Second = Arg::None, Arg arg2Second = Arg::None);
33
+
34
+		const QString &getName() const;
35
+		unsigned char getOpcode() const;
36
+		const QList<Arg> &getArgList() const;
37
+
38
+		unsigned char getOpcodeSecond() const;
39
+		const QList<Arg> &getArgSecondList() const;
40
+
41
+	private:
42
+		QString name; //!< Instruction name
43
+		unsigned char opcode; //!< Opcode of the defined instruction
44
+		QList<Arg> argList; //!< Argument list of the defined instruction
45
+
46
+		unsigned char opcodeSecond; //!< Second optional opcode of the defined instruction used for a two-step instruction type
47
+		QList<Arg> argSecondList; //!< Second optional argument list of the defined instruction used for a two-step instruction type
48
+};
49
+
50
+#endif