diff --git a/libs/mips/include/mips/mips_manager.h b/libs/mips/include/mips/mips_manager.h index 8413eb0..f18c33f 100644 --- a/libs/mips/include/mips/mips_manager.h +++ b/libs/mips/include/mips/mips_manager.h @@ -31,6 +31,7 @@ class MipsManager { ZeroReg *zero; StkPtrReg *sp; RetAddrReg *ra; + ArgumentReg *a0; ValueReg *v0; // f0 和 f12 保留,用于输入输出 FloatReg *f0; diff --git a/libs/mips/src/mips_manager.cpp b/libs/mips/src/mips_manager.cpp index 10fba36..01ba060 100644 --- a/libs/mips/src/mips_manager.cpp +++ b/libs/mips/src/mips_manager.cpp @@ -15,6 +15,7 @@ MipsManager::MipsManager() { zero = new ZeroReg(); sp = new StkPtrReg(); ra = new RetAddrReg(); + a0 = new ArgumentReg(0); v0 = new ValueReg(0); f0 = new FloatReg(0); f12 = new FloatReg(12); @@ -42,6 +43,7 @@ MipsManager::~MipsManager() { delete zero; delete sp; delete ra; + delete a0; delete v0; delete f0; delete f12; diff --git a/libs/mips/src/translator.cpp b/libs/mips/src/translator.cpp index 8b0bcca..ecd2f2b 100644 --- a/libs/mips/src/translator.cpp +++ b/libs/mips/src/translator.cpp @@ -416,4 +416,8 @@ void Translator::translate(OutputInstPtr outputInstPtr) { manager->addCode(new RCode(AddS, manager->f12, reg, reg0)); manager->addCode(new ICode(Addiu, manager->v0, manager->zero, 2)); manager->addCode(new RCode(Syscall)); + // for test: put '\n' + manager->addCode(new ICode(Addiu, manager->a0, manager->zero, 10)); + manager->addCode(new ICode(Addiu, manager->v0, manager->zero, 11)); + manager->addCode(new RCode(Syscall)); } diff --git a/tests/test_mips.cpp b/tests/test_mips.cpp index aa27123..677789b 100644 --- a/tests/test_mips.cpp +++ b/tests/test_mips.cpp @@ -146,6 +146,9 @@ l.s $f14, flt1 add.s $f12, $f13, $f14 addiu $v0, $zero, 2 syscall +addiu $a0, $zero, 10 +addiu $v0, $zero, 11 +syscall j main_5 nop