Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added op_nor (passes)

  • Loading branch information...
commit cd26cc179529b5e3ca011aea4419e93185d57b77 1 parent c8b08ef
@sztomi authored
Showing with 37 additions and 0 deletions.
  1. +7 −0 src/mipscpu.cpp
  2. +1 −0  src/mipscpu.h
  3. +29 −0 test/main.cpp
View
7 src/mipscpu.cpp
@@ -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()
@@ -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;
View
1  src/mipscpu.h
@@ -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;
View
29 test/main.cpp
@@ -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);
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.