Skip to content

Commit

Permalink
added op_nor (passes)
Browse files Browse the repository at this point in the history
  • Loading branch information
sztomi committed May 3, 2011
1 parent c8b08ef commit cd26cc1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mipscpu.cpp
Expand Up @@ -78,6 +78,7 @@ namespace tememu
REG_OP_FUNC(op_or, 0x25 << 4);
REG_OP_FUNC(op_ori, 0x0D);
REG_OP_FUNC(op_xor, 0x26 << 4);
REG_OP_FUNC(op_nor, 0x27 << 4);
}

void MipsCPU::reset()
Expand Down Expand Up @@ -297,6 +298,12 @@ namespace tememu
step();
}

void MipsCPU::op_nor(int32 instr)
{
_GPR[RD(instr)] = ~(_GPR[RS(instr)] | _GPR[RT(instr)]);
step();
}

void MipsCPU::loadProgram(boost::shared_ptr< std::vector<int32> > program)
{
_program = program;
Expand Down
1 change: 1 addition & 0 deletions src/mipscpu.h
Expand Up @@ -108,6 +108,7 @@ namespace tememu
void op_or(int32);
void op_ori(int32);
void op_xor(int32);
void op_nor(int32);

private:
std::vector<int32> _GPR, _FPR, _FCR;
Expand Down
29 changes: 29 additions & 0 deletions test/main.cpp
Expand Up @@ -596,3 +596,32 @@ TEST(Logical, op_xor)
cpu.runProgram();
EXPECT_EQ(cpu.gprValue(7), 0x0ff00ff0);
}

TEST(Logical, op_nor)
{
tememu::MipsCPU cpu;
boost::shared_ptr< std::vector<int32> > program(new std::vector<int32>);

program->push_back(0x00a63827); // xor $a3, $a1, $a2
cpu.loadProgram(program);

cpu.setGPR(5, 0xffffffff);
cpu.setGPR(6, 0);
cpu.runProgram();
EXPECT_EQ(cpu.gprValue(7), 0);

cpu.reset();

cpu.setGPR(5, 0x0000ffff);
cpu.setGPR(6, 0xfffff000);
cpu.runProgram();
EXPECT_EQ(cpu.gprValue(7), 0);

cpu.reset();

cpu.setGPR(5, 0xff00ff00);
cpu.setGPR(6, 0xf0f0f0f0);
cpu.runProgram();
EXPECT_EQ(cpu.gprValue(7), 0x000f000f);
}

0 comments on commit cd26cc1

Please sign in to comment.