-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.txt
More file actions
243 lines (195 loc) · 11 KB
/
log.txt
File metadata and controls
243 lines (195 loc) · 11 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#Log
10/27/2016
Moved each file into a Visual Studio project
Commented out the necessary code to have an 'error free' program that does absolutely nothing.
Added comments as a header to each file.
11/2/2016 - 11/3/2016
Added Instruction.cpp
Commented the FileAccess.cpp according to documentation specifications.
Considering how to tackle Instuction.cpp
(i) Commented line
(a) At the end of the line...
(b) On a line of it's own...
(ii) Machine Language Instruction
(a) ADD | SUB | MULT | DIV | LOAD | STORE | READ | WRITE | B | BM |BZ |BP | HALT
(1) translate to 01-13 respectively.
(b) Where are we storing the OP Code? Should I make an enum for this?
(iii) Assembly Language instruction
(a) DC | DS | ORG | END
(iv) Labels!
(a) Has to be within the first "column" [use counter for this :: # of words read from the line]
(b) if not, there *should not* be a label [if there is, either misplaced comment or incorrect (ERROR)].
Data structures to consider ("helpful" structures):
vector<pair<enum, "string">> :: preventing a long if-else statement (condense to a for-loop)
:: holding the enum / "opcode" [01-13] equivalent of the instruction ("helpful")
arrays for machine_type | assembly :: preventing extensive if-else [no opcode:: 000]
Questions to consider:
#1 : Separate parts (i-iv) into different private member functions? Yes, for Assem | Machine
#2 : Upon finding type, what needs to be stored based on that type? (check symbole table | pass1 v pass2)
##Work In Progress##
(A)CLASS: Instruction.cpp
FUNCTIONS: Instruction::InstructionType Instruction::ParseInstruction(string &a_buff);
bool Instruction::isAssemInstruct(string &a_section, int &a_count);
bool Instruction::isMachineInstruct(string &a_section, int &a_count);
HEADER: Instruction.h
ADDITIONS: vector for a list of machine instructions,
vector for a list of assembly instructions,
number of op_codes(machine) constant,
##Testing##
;comments! with blank space before /t and ' '.
Single-line (first line in the file, nothing after) :: WORKS!
Multiple-lines of comments (varying spacing) :: WORKS!
*For comments on their own line!
Machine! works with the blank space in front
Successfully stores the numerical and string value of the opCode
(opcode only, no other information)
Assembly! works with blank space in front
Successfully stores the string value of the opCode
These tests are only for JUST the instruction : ensuring the comparisons were working.
Can mix and match instructions on their own lines and it will still work.
NOTE :: need to make something to handle empty strings.
11/25/2016
Began considering the symbol class, uncommented the corresponding code in Assembly.cpp
12/1/2016
Working on the symbol table display functionality.
Thoughts on Instruction class:
boolean value for isNumericOperand, should be only in the "3rd column" .. Require lookup in symbol table?
integer value for numericOperand, should be only in the "3rd column" assigned when you have a "variable" in its place
or when the value is explicitly given (ie ORG)
Need to implement: (1) finding whether an instruction is a numerical value.
(2) finding the next instruction location (which requires me to do (1).
12/3/2016
Realized last log entry I was making things much more complicated than need be, therefore,
I'm taking a break a bit and using a different data structure for instruction lookup.
- used to be VECTOR < MachineOpCode, string > m_MachList
- merging to UNORDERED_MAP < string, MachineOpCode > m_MachList
In doing this, need to restructure the isAssemInstruct && isMachInstruct functions.
BEFORE:
bool Instruction::isAssemInstruct(const string &a_section, int &a_count) {
for (int i = 0; i < m_AssemList.size(); i++) {
if (m_AssemList[i].second != a_section) continue;
else {
//Conclusion: is an assembler instruction
//reached the matching assembly string set necessary values
m_OpCode = m_AssemList[i].second;
cout << "[string] opcode: "<< m_OpCode << endl;
m_NumOpCode = 0;
if (m_AssemList[i].first == AT_END) m_type = ST_End;
else m_type = ST_AssemblerInstr;
if (a_count == 1) {
//increase column count because we're technically in "column two"
a_count++;
}
return true;
}
}
//will not increment count on FALSE
return false;
}
AFTER:
bool Instruction::isAssemInstruct(const string &a_section, int &a_count) {
auto it = m_AssemList.find(a_section);
if (it != m_AssemList.end()) {
//found the opcode string
m_OpCode = it->first;
m_NumOpCode = 0; //AL does not have opcodes
if (it->second == AT_END) m_type = ST_End;
else m_type = ST_AssemblerInstr;
if (a_count = 1) {
a_count += 1;
}
return true;
}
return false;
}
Accomplished : - Fixing the operand variables and obtaining values. Upon doing so, began creating a list of questions for Miller about the specs.
- Finished LocationNextInstruction, **testing required.
12/4/2016
Building and testing the project for specifically the instruction types and what is being held in the variables at the end of each line read.
Will be doing this for each line, and then testing the symbol table display as well as variable location testing. (declarations)
Minor error noticed in Instruction::ParseInstruction(...) :
(1) [FIXED with Instruction::checkComment(string &a_section)]
When comment occured directly after an operand, the operand + comment was in the string while parsing the line.
Minor error within debugger to consider:
(1) 'Instruction::LocationNextInstruction': not all control paths return a value
12/5/2016
Fixed the debugger error from yesterday (was unhappy about an if else case). Simply ended function with return loc + 1;
Finishing up testing on PassI :: Symbol table printing correctly, parsing each line... except one.
BUGS:
(1) [FIXED 12/07/2016]When testing, would read through each line and correctly store the value and location except label B, which happens
to occur after the *only* ds statement. Looking into this...
Found answer : the parser believes "b" is an assembly instruction! Oh dear...
POSSIBLE FIX (needs testing) re-wrote the parseinstruction re-organizing the code and putting relevant LABEL | INSTR | OPERAND within a vector for each line.
12/7/2016
FIXed BUGS(1) from Monday.
Began setting up PassII() and laying out the process with comments.
Translation stages :: should just focus on the translation of a line for now, then focus on errors.
**Commenting in where I believe errors would logically occur for future reference (with "//Error::" or something along those lines)
12/8/2016
Filled in the Error Class, since it was just display, initialize and insert type functions. (May need to come back and fix this later)
Added iomanip to the stdfx file, for setting precision in printing the instruction location as well as the value/location.
To find get location + value, need to look up if it is in the symbol table already [if it's not :: error], if it is then get the value.
When checking Errors that need comparison to the Symbol Table, check it in the Assembler.cpp class (since Instruction does not have access), this will keep everything as condensed as it will get.
Questions:
(1) How to update the Error Class? In Assembler.cpp as well as Instruction.cpp?
(2) How many errors to "hold onto" at once? When to report them?
(3) Allowed to add functions to Assembler.cpp for error-checking?
12/9/2016
Thoughts:
* Probably should just error report in Assembler.cpp, and use inline get calls to get the values of the variables within Instruction.cpp... it's a start!
* Could keep a LINE COUNT for the error and apply it to the Error Reporting
* Print out copy of Errors to check, and do a checklist (starting to get confusing otherwise!)
Accomplished:
Error class, learning of proper use of static functions.
find_if functionality for checking appropriate use of Labels/Operands.
Error Class :
createError functionality, where it will take in a line number, location, and then the corresponding message.
reportCurrentError functionality, where it will just display the last Error pushed onto the vector [vector.back()]
Instruction Class :
isNumeric functionality, where it displays if a string contains all integers.
validating labels/operands, where it examines the first element, then proceeds to check each other element for alphanumeric characters.
Tomorrow ::
Focus on Instruction.cpp where Errors will be reported, we have the skeleton of details now, so it just comes down to implementing in the appropriate places.
Hopefully will have an answer from Miller about the sizes and if the Error vector should be declared in a specific place in the Error.cpp file.
12/10/2016
Error Reporting in Assembler & Instruction class. Still need:
(1) Reporting an error if a symbol is not used in the table.
(2) Reporting an error for insuffecient memory (see e-mail conversation with Miller)
(3) Reporting an error if Constant is too large for VC 3600 memory (see e-mail conversation with Miller)
(4) Replacing undefined operand's location/address as (insert value)
(5) Replacing unknown operator as (insert value)
12/12/2016
* Between yesterday and today, finished up error reporting.
* Translation was successful after a few attempts today, and finding specific cases to handle based upon Machine Language instruction or Assembly Language Instruction.
* Storing the information found within the assembler class into the emulator structure.
* Considering the private member functions of the emulator :
* 01 ADD
* 02 SUB
* 03 MULT
* 04 DIV :: check division by zero
* 05 LOAD
* 06 STORE
* 07 READ :: check if an integer entered
* 08 WRITE
* 09 B :: valid addresses were checked _before_ entering the emulation, shouldn't be a problem.
* 10 BM
* 11 BZ
* 12 BP
* 13 HALT :: output a little success message, will go back to main. (assem.cpp)
* Switch statement seems necessary per instruction in the emulator.
* Finished the basic code for emulation, made functions for _each_ function mentioned above. Might be excessive because they're all short, however, it makes the code less intimidating.
* REQUIRED ::
* Emulation Testing - required, clearly only need to test _working_ .txt files.
* Coding Standards, especially in the emulator.cpp; currently has no comments above the classes.
* Fix the Coding Standards on the other functions before the "Name" header. (supposed to have the name of the function twice)
* Add Copyright footers at the bottom of each class / header file.
12/13/2016
Working code completed :: move functions in the emulat
12/22/2016
* Commenting code
* Assembler.cpp
* Changed casing on variables & functions
* Moved the #include<vector> out of Errors.h and put it in stdafx.h
* Deleted duplicate includes in stdafx, added includes from FileAccess, while removing those that were already within the stdafx.h
* BUG :: does not handle when a label is on the HALT instruction
* Assumption :: Assumes the numerical values taken by the DC/DS instructions are positive, however, handles negative input...