Files
The-VM-to-HACK-Translator/code_writer.hpp

29 lines
763 B
C++
Raw Normal View History

2020-08-18 21:31:36 +05:30
#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);
};