-
Notifications
You must be signed in to change notification settings - Fork 5
/
CodeTranslator.h
39 lines (31 loc) · 1.09 KB
/
CodeTranslator.h
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
/*
* Created by Francois W. Nel on 27 Jun 2016.
*/
#ifndef HACK_ASSEMBLER_CODE_H
#define HACK_ASSEMBLER_CODE_H
#include <iostream>
#include <map>
using namespace std;
class CodeTranslator {
public:
CodeTranslator();
// Populates the code translation map tables
// with the language specification.
string dest(string destMnemonic, unsigned long& lineNr);
// Returns the binary code of the destination mnemonic
// as a string containing 3 bits.
// Line number is passed for use in an error message.
string comp(string compMnemonic, unsigned long& lineNr);
// Returns the binary code of the computation mnemonic
// as a string containing 7 bits.
// Line number is passed for use in an error message.
string jump(string jumpMnemonic, unsigned long& lineNr);
// Returns the binary code of the jump mnemonic
// as a string containing 3 bits.
// Line number is passed for use in an error message.
private:
map<string, string> destTable;
map<string, string> compTable;
map<string, string> jumpTable;
};
#endif //HACK_ASSEMBLER_CODE_H