working code writer program

This commit is contained in:
avinal
2020-08-18 21:31:36 +05:30
parent a8276b78cc
commit c28474940a
2 changed files with 418 additions and 0 deletions

28
code_writer.hpp Normal file
View File

@@ -0,0 +1,28 @@
#include "parser.hpp"
#include <functional>
class code_writer
{
private:
std::string file_name;
std::vector<vmcommand> commands;
std::ofstream outfile;
int ins_no = -1;
bool dbg = false;
public:
code_writer(std::string name);
void write_assembly();
void write_push(std::string segment, int index, bool debug);
void write_pop(std::string segment, int index, bool debug);
void write_arithmetic(std::string comm, int index, bool debug);
void write_add(bool debug);
void write_sub(bool debug);
void write_neg(bool debug);
void write_and(bool debug);
void write_or(bool debug);
void write_not(bool debug);
void write_eq(bool debug);
void write_lt(bool debug);
void write_gt(bool debug);
};