Skip to content

Commit

Permalink
#76: funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
levBagryansky committed Dec 20, 2023
1 parent e7962db commit 39a4bb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion include/frontend/assembler/assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class Assembler final {
chai::bytecode_t processCall(chai::interpreter::Operation op) {
auto val = static_cast<uint64_t>(
static_cast<AsmLex::Int *>(lex_.nextLexem().get())->value);
return chai::utils::instr2Raw(op, val, 0);
std::cout << "[Call]: val = " << val << std::endl;
return chai::utils::instr2RawRI(op, val, val);
}
chai::bytecode_t processN(chai::interpreter::Operation op) {
return chai::utils::instr2Raw(op, 0, 0);
Expand Down
10 changes: 3 additions & 7 deletions test/frontend/assembler/assembler-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,16 @@ TEST_F(AssemblerTest, runWithStrings) {

TEST_F(AssemblerTest, runWithFunctions) {
write_input_ << "Ldia 271\n"
<< "Star r99\n"
<< "Ldia 314\n"
<< "Star r98\n"
<< "Call 10\n"
<< "Call 8\n"
<< "Ret\n"
<< "fn aboba_func 50 2 {\n"
<< "Ldra r49\n"
<< "Sub r48\n"
<< "Ldia 125\n"
<< "Ret\n"
<< "}\n" << std::endl;
Assembler asM{input_, output_};
asM.assemble();
codeManager_.load(output_);
exec_.run();
EXPECT_EQ(static_cast<int64_t>(exec_.acc()), 314 - 271);
EXPECT_EQ(static_cast<int64_t>(exec_.acc()), 125);
EXPECT_EQ(exec_.getCurrentFrame(), nullptr);
}

0 comments on commit 39a4bb9

Please sign in to comment.