CDat rb = this->m_cpu->getRegister(m_rb);
CDatd val = ra + rb;
this->m_cpu->setRegister(m_rd, val);
- this->m_cpu->updateFlags(val, ra, rb);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(val, ra, rb);
+ }
}
std::string Cadd::toString()
CDat ra = this->m_cpu->getRegister(m_ra);
CDatd reg = ra + this->m_imm;
this->m_cpu->setRegister(m_rd, reg);
- this->m_cpu->updateFlags(reg, ra, this->m_imm);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(reg, ra, this->m_imm);
+ }
}
std::string Caddi::toString()
--- /dev/null
+#include "../Iinstr.hpp"
+
+class Cand : public Iinstr {
+ public:
+ Cand();
+ void evalInstr();
+ void execInstr();
+ std::string toString();
+ Iinstr* getNew();
+};
+
+/**
+ * Name: create_instruction
+ * Purpose: if compiled as shared library, this functions creates the
+ instruction object
+
+ * Returns: pointer to instruction object
+ */
+extern "C" Iinstr* create_instruction() {
+ return new Cand();
+}
+
+Iinstr* Cand::getNew() {
+ return new Cand();
+}
+
+/**
+ * Name: destroy_instruction
+ * Purpose: if compiled as shared library, this functions destoys the
+ instruction object
+
+ * Parameter: IInstruction - the instruction object to delete
+ */
+extern "C" void destroy_instruction(Iinstr* p) {
+ delete p;
+}
+
+Cand::Cand()
+{
+ opcode = B5(00100);
+ name = "and";
+}
+
+void Cand::evalInstr()
+{
+ this->m_d = argbits[0];
+
+ argbits >>= 11;
+ m_rb = this->getRegister(argbits);
+
+ argbits >>= 4;
+ m_ra = this->getRegister(argbits);
+
+ argbits >>= 4;
+ m_rd = this->getRegister(argbits);
+}
+
+void Cand::execInstr()
+{
+ //cout << "should exec " << this->toString() << endl;
+ CDat ra = this->m_cpu->getRegister(m_ra);
+ CDat rb = this->m_cpu->getRegister(m_rb);
+ CDat val = ra & rb;
+ this->m_cpu->setRegister(m_rd, val);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(val);
+ }
+}
+
+std::string Cand::toString()
+{
+ stringstream op;
+ op << this->getName();
+
+ if(m_d) op << 'D';
+ if(m_c) op << 'C';
+
+ op << " r" << m_rd << ", r" << m_ra << ", r" << m_rb;
+ return op.str();
+}
--- /dev/null
+#include "../Iinstr.hpp"
+
+
+class Candx : public Iinstr {
+ public:
+ Candx();
+ void evalInstr();
+ void execInstr();
+ std::string toString();
+ Iinstr* getNew();
+};
+
+/**
+ * Name: create_instruction
+ * Purpose: if compiled as shared library, this functions creates the
+ instruction object
+
+ * Returns: pointer to instruction object
+ */
+extern "C" Iinstr* create_instruction() {
+ return new Candx();
+}
+
+Iinstr* Candx::getNew()
+{
+ return new Candx();
+}
+/**
+ * Name: destroy_instruction
+ * Purpose: if compiled as shared library, this functions destoys the
+ instruction object
+
+ * Parameter: IInstruction - the instruction object to delete
+ */
+extern "C" void destroy_instruction(Iinstr* p) {
+ delete p;
+}
+
+Candx::Candx()
+{
+ opcode = B5(00101);
+ name = "andx";
+}
+
+void Candx::evalInstr()
+{
+ this->m_d = argbits[0];
+ this->m_f = argbits[1];
+ this->m_hl = argbits[2];
+
+ argbits >>= 3;
+ dynamic_bitset<> immb = argbits;
+ immb.resize(16);
+ this->m_imm = this->generate16ImmSign(immb.to_ulong());
+
+ argbits >>= 16;
+ m_rd = this->getRegister(argbits);
+}
+
+void Candx::execInstr()
+{
+ CDat val = this->m_cpu->getRegister(this->m_rd);
+ CDat imm = generate16ImmFill(this->m_imm);
+ val &= imm;
+
+ this->m_cpu->setRegister(this->m_rd, val);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(val);
+ }
+}
+
+std::string Candx::toString()
+{
+ stringstream op;
+ op << this->getName();
+
+ if(m_hl) op << 'H';
+ if(m_f) op << 'F';
+ if(m_d) op << 'D';
+
+ op << this->getConditionFlag() << " r" << m_rd << ", " << m_imm;
+
+ return op.str();
+}
--- /dev/null
+#include "../Iinstr.hpp"
+
+class Cor : public Iinstr {
+ public:
+ Cor();
+ void evalInstr();
+ void execInstr();
+ std::string toString();
+ Iinstr* getNew();
+};
+
+/**
+ * Name: create_instruction
+ * Purpose: if compiled as shared library, this functions creates the
+ instruction object
+
+ * Returns: pointer to instruction object
+ */
+extern "C" Iinstr* create_instruction() {
+ return new Cor();
+}
+
+Iinstr* Cor::getNew() {
+ return new Cor();
+}
+
+/**
+ * Name: destroy_instruction
+ * Purpose: if compiled as shared library, this functions destoys the
+ instruction object
+
+ * Parameter: IInstruction - the instruction object to delete
+ */
+extern "C" void destroy_instruction(Iinstr* p) {
+ delete p;
+}
+
+Cor::Cor()
+{
+ opcode = B5(00110);
+ name = "or";
+}
+
+void Cor::evalInstr()
+{
+ this->m_d = argbits[0];
+
+ argbits >>= 11;
+ m_rb = this->getRegister(argbits);
+
+ argbits >>= 4;
+ m_ra = this->getRegister(argbits);
+
+ argbits >>= 4;
+ m_rd = this->getRegister(argbits);
+}
+
+void Cor::execInstr()
+{
+ //cout << "should exec " << this->toString() << endl;
+ CDat ra = this->m_cpu->getRegister(m_ra);
+ CDat rb = this->m_cpu->getRegister(m_rb);
+ CDat val = ra | rb;
+ this->m_cpu->setRegister(m_rd, val);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(val);
+ }
+}
+
+std::string Cor::toString()
+{
+ stringstream op;
+ op << this->getName();
+
+ if(m_d) op << 'D';
+ if(m_c) op << 'C';
+
+ op << " r" << m_rd << ", r" << m_ra << ", r" << m_rb;
+ return op.str();
+}
--- /dev/null
+#include "../Iinstr.hpp"
+
+
+class Corx : public Iinstr {
+ public:
+ Corx();
+ void evalInstr();
+ void execInstr();
+ std::string toString();
+ Iinstr* getNew();
+};
+
+/**
+ * Name: create_instruction
+ * Purpose: if compiled as shared library, this functions creates the
+ instruction object
+
+ * Returns: pointer to instruction object
+ */
+extern "C" Iinstr* create_instruction() {
+ return new Corx();
+}
+
+Iinstr* Corx::getNew()
+{
+ return new Corx();
+}
+/**
+ * Name: destroy_instruction
+ * Purpose: if compiled as shared library, this functions destoys the
+ instruction object
+
+ * Parameter: IInstruction - the instruction object to delete
+ */
+extern "C" void destroy_instruction(Iinstr* p) {
+ delete p;
+}
+
+Corx::Corx()
+{
+ opcode = B5(00111);
+ name = "orx";
+}
+
+void Corx::evalInstr()
+{
+ this->m_d = argbits[0];
+ this->m_f = argbits[1];
+ this->m_hl = argbits[2];
+
+ argbits >>= 3;
+ dynamic_bitset<> immb = argbits;
+ immb.resize(16);
+ this->m_imm = this->generate16ImmSign(immb.to_ulong());
+
+ argbits >>= 16;
+ m_rd = this->getRegister(argbits);
+}
+
+void Corx::execInstr()
+{
+ CDat val = this->m_cpu->getRegister(this->m_rd);
+ CDat imm = generate16ImmFill(this->m_imm);
+ val |= imm;
+
+ this->m_cpu->setRegister(this->m_rd, val);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(val);
+ }
+}
+
+std::string Corx::toString()
+{
+ stringstream op;
+ op << this->getName();
+
+ if(m_hl) op << 'H';
+ if(m_f) op << 'F';
+ if(m_d) op << 'D';
+
+ op << this->getConditionFlag() << " r" << m_rd << ", " << m_imm;
+
+ return op.str();
+}
--- /dev/null
+#include "../Iinstr.hpp"
+
+class Csub : public Iinstr {
+ public:
+ Csub();
+ void evalInstr();
+ void execInstr();
+ std::string toString();
+ Iinstr* getNew();
+};
+
+/**
+ * Name: create_instruction
+ * Purpose: if compiled as shared library, this functions creates the
+ instruction object
+
+ * Returns: pointer to instruction object
+ */
+extern "C" Iinstr* create_instruction() {
+ return new Csub();
+}
+
+Iinstr* Csub::getNew() {
+ return new Csub();
+}
+
+/**
+ * Name: destroy_instruction
+ * Purpose: if compiled as shared library, this functions destoys the
+ instruction object
+
+ * Parameter: IInstruction - the instruction object to delete
+ */
+extern "C" void destroy_instruction(Iinstr* p) {
+ delete p;
+}
+
+Csub::Csub()
+{
+ opcode = B5(00001);
+ name = "sub";
+}
+
+void Csub::evalInstr()
+{
+ this->m_d = argbits[0];
+ this->m_c = argbits[1];
+
+ argbits >>= 11;
+ m_rb = this->getRegister(argbits);
+
+ argbits >>= 4;
+ m_ra = this->getRegister(argbits);
+
+ argbits >>= 4;
+ m_rd = this->getRegister(argbits);
+}
+
+void Csub::execInstr()
+{
+ //cout << "should exec " << this->toString() << endl;
+ CDat ra = this->m_cpu->getRegister(m_ra);
+ CDat rb = this->m_cpu->getRegister(m_rb);
+ CDatd val = ra - rb;
+ this->m_cpu->setRegister(m_rd, val);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(val, ra, rb);
+ }
+}
+
+std::string Csub::toString()
+{
+ stringstream op;
+ op << this->getName();
+
+ if(m_d) op << 'D';
+ if(m_c) op << 'C';
+
+ op << " r" << m_rd << ", r" << m_ra << ", r" << m_rb;
+ return op.str();
+}
CDat ra = this->m_cpu->getRegister(m_ra);
CDatd reg = ra - this->m_imm;
this->m_cpu->setRegister(m_rd, reg);
- this->m_cpu->updateFlags(reg, ra, this->m_imm);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(reg, ra, this->m_imm);
+ }
}
std::string Csubi::toString()
--- /dev/null
+#include "../Iinstr.hpp"
+
+class Cxor : public Iinstr {
+ public:
+ Cxor();
+ void evalInstr();
+ void execInstr();
+ std::string toString();
+ Iinstr* getNew();
+};
+
+/**
+ * Name: create_instruction
+ * Purpose: if compiled as shared library, this functions creates the
+ instruction object
+
+ * Returns: pointer to instruction object
+ */
+extern "C" Iinstr* create_instruction() {
+ return new Cxor();
+}
+
+Iinstr* Cxor::getNew() {
+ return new Cxor();
+}
+
+/**
+ * Name: destroy_instruction
+ * Purpose: if compiled as shared library, this functions destoys the
+ instruction object
+
+ * Parameter: IInstruction - the instruction object to delete
+ */
+extern "C" void destroy_instruction(Iinstr* p) {
+ delete p;
+}
+
+Cxor::Cxor()
+{
+ opcode = B5(01000);
+ name = "or";
+}
+
+void Cxor::evalInstr()
+{
+ this->m_d = argbits[0];
+
+ argbits >>= 11;
+ m_rb = this->getRegister(argbits);
+
+ argbits >>= 4;
+ m_ra = this->getRegister(argbits);
+
+ argbits >>= 4;
+ m_rd = this->getRegister(argbits);
+}
+
+void Cxor::execInstr()
+{
+ //cout << "should exec " << this->toString() << endl;
+ CDat ra = this->m_cpu->getRegister(m_ra);
+ CDat rb = this->m_cpu->getRegister(m_rb);
+ CDat val = ra ^ rb;
+ this->m_cpu->setRegister(m_rd, val);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(val);
+ }
+}
+
+std::string Cxor::toString()
+{
+ stringstream op;
+ op << this->getName();
+
+ if(m_d) op << 'D';
+ if(m_c) op << 'C';
+
+ op << " r" << m_rd << ", r" << m_ra << ", r" << m_rb;
+ return op.str();
+}
--- /dev/null
+#include "../Iinstr.hpp"
+
+
+class Cxorx : public Iinstr {
+ public:
+ Cxorx();
+ void evalInstr();
+ void execInstr();
+ std::string toString();
+ Iinstr* getNew();
+};
+
+/**
+ * Name: create_instruction
+ * Purpose: if compiled as shared library, this functions creates the
+ instruction object
+
+ * Returns: pointer to instruction object
+ */
+extern "C" Iinstr* create_instruction() {
+ return new Cxorx();
+}
+
+Iinstr* Cxorx::getNew()
+{
+ return new Cxorx();
+}
+/**
+ * Name: destroy_instruction
+ * Purpose: if compiled as shared library, this functions destoys the
+ instruction object
+
+ * Parameter: IInstruction - the instruction object to delete
+ */
+extern "C" void destroy_instruction(Iinstr* p) {
+ delete p;
+}
+
+Cxorx::Cxorx()
+{
+ opcode = B5(01001);
+ name = "xorx";
+}
+
+void Cxorx::evalInstr()
+{
+ this->m_d = argbits[0];
+ this->m_f = argbits[1];
+ this->m_hl = argbits[2];
+
+ argbits >>= 3;
+ dynamic_bitset<> immb = argbits;
+ immb.resize(16);
+ this->m_imm = this->generate16ImmSign(immb.to_ulong());
+
+ argbits >>= 16;
+ m_rd = this->getRegister(argbits);
+}
+
+void Cxorx::execInstr()
+{
+ CDat val = this->m_cpu->getRegister(this->m_rd);
+ CDat imm = generate16ImmFill(this->m_imm);
+ val ^= imm;
+
+ this->m_cpu->setRegister(this->m_rd, val);
+ if(!this->m_d) {
+ this->m_cpu->updateFlags(val);
+ }
+}
+
+std::string Cxorx::toString()
+{
+ stringstream op;
+ op << this->getName();
+
+ if(m_hl) op << 'H';
+ if(m_f) op << 'F';
+ if(m_d) op << 'D';
+
+ op << this->getConditionFlag() << " r" << m_rd << ", " << m_imm;
+
+ return op.str();
+}