Skip to content

Commit

Permalink
fix bug for print
Browse files Browse the repository at this point in the history
  • Loading branch information
Asterism12 committed Dec 26, 2019
1 parent d64056f commit 46fed7a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions analyser/analyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ void Analyser::analyse_print_statement()
unreadToken();
while (analyse_expression()) {
addInstruction(Instruction(Operation::iprint));
addInstruction(Instruction(Operation::printl));
next = nextToken();
if (!next.has_value()) {
throw Error("Missing ')'", _currentLine);
Expand Down
3 changes: 2 additions & 1 deletion assembler/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ std::map<Operation, std::string> ITATable = {
{Operation::iscan,"iscan"},
{Operation::iload,"iload"},
{Operation::istore,"istore"},
{Operation::ineg,"ineg"}
{Operation::ineg,"ineg"},
{Operation::printl,"printl"}
};

std::string Assembler::instructionToAssembly(Instruction & ins) {
Expand Down
3 changes: 2 additions & 1 deletion compiler/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ std::map<Operation, char*> ITCTable = {
{Operation::iscan,"\xb0"},
{Operation::iload,"\x10"},
{Operation::istore,"\x20"},
{Operation::ineg,"\x40"}
{Operation::ineg,"\x40"},
{Operation::printl,"\xaf"}//0
};

void Compiler::instructionToBinary(Instruction& ins) {
Expand Down
3 changes: 2 additions & 1 deletion instruction/instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum class Operation {
iscan,
iload,
istore,
ineg
ineg,
printl
};

class Instruction final {
Expand Down

0 comments on commit 46fed7a

Please sign in to comment.