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,99 @@
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
+#include "codeitem.h"
13
+
14
+/**
15
+ * Constructor for creating a code item
16
+ *
17
+ * @param line Line number in the source file
18
+ * @param name Name of the instruction
19
+ * @param paramList List of parameters for the instruction
20
+ */
21
+CodeItem::CodeItem(int line, const QString &name, const QList<QString> &paramList)
22
+{
23
+	this->line = line;
24
+	this->name = name;
25
+
26
+	this->paramList = paramList;
27
+
28
+	this->address = 0;
29
+}
30
+
31
+/**
32
+ * Get the line number where the instruction occurred
33
+ *
34
+ * @return Line number in the source file
35
+ */
36
+int CodeItem::getLine() const
37
+{
38
+	return(this->line);
39
+}
40
+
41
+/**
42
+ * Get the name of the instruction
43
+ *
44
+ * @return Name of the instruction
45
+ */
46
+const QString &CodeItem::getName() const
47
+{
48
+	return(this->name);
49
+}
50
+
51
+/**
52
+ * Get the parameter list of the instruction
53
+ *
54
+ * @return Parameter list of the instruction
55
+ */
56
+const QList<QString> &CodeItem::getParamList() const
57
+{
58
+	return(this->paramList);
59
+}
60
+
61
+/**
62
+ * Get the list of machine instructions generated from the assembler instruction
63
+ *
64
+ * @return List of machine instruction
65
+ */
66
+QVector<unsigned char> &CodeItem::getDataVector()
67
+{
68
+	return(this->dataVector);
69
+}
70
+
71
+/**
72
+ * Get the list of address needed to fill up during linking
73
+ *
74
+ * @return List of address needed to fill up during linking
75
+ */
76
+QHash<QString, unsigned int> &CodeItem::getToFillUpHash()
77
+{
78
+	return(this->toFillUpHash);
79
+}
80
+
81
+/**
82
+ * Set the address in the memory
83
+ *
84
+ * @param address Address in the memory
85
+ */
86
+void CodeItem::setAddress(unsigned int address)
87
+{
88
+	this->address = address;
89
+}
90
+
91
+/**
92
+ * Get the address in the memory
93
+ *
94
+ * @return Address in the memory
95
+ */
96
+unsigned int CodeItem::getAddress() const
97
+{
98
+	return(this->address);
99
+}