Skip to content

Commit

Permalink
[fix](mips): add \n for test
Browse files Browse the repository at this point in the history
  • Loading branch information
XingZiiii committed Aug 31, 2024
1 parent 69814d7 commit a3a486f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/mips/include/mips/mips_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class MipsManager {
ZeroReg *zero;
StkPtrReg *sp;
RetAddrReg *ra;
ArgumentReg *a0;
ValueReg *v0;
// f0 和 f12 保留,用于输入输出
FloatReg *f0;
Expand Down
2 changes: 2 additions & 0 deletions libs/mips/src/mips_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -42,6 +43,7 @@ MipsManager::~MipsManager() {
delete zero;
delete sp;
delete ra;
delete a0;
delete v0;
delete f0;
delete f12;
Expand Down
4 changes: 4 additions & 0 deletions libs/mips/src/translator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
3 changes: 3 additions & 0 deletions tests/test_mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a3a486f

Please sign in to comment.