disasm/sim: bugfix for ldi
authorMartin Perner <martin@perner.cc>
Sun, 31 Oct 2010 13:26:52 +0000 (14:26 +0100)
committerMartin Perner <martin@perner.cc>
Sun, 31 Oct 2010 22:32:48 +0000 (23:32 +0100)
3c_disasm/instr/ldi.cpp

index 095a1447ffb75688ad7305bbd7e580eac3be97c4..bb18c286dc97e49510a408a08d17973de9c5e4db 100644 (file)
@@ -59,7 +59,19 @@ void Cldi::evalInstr()
 void Cldi::execInstr()
 {
        //cout << "should exec " << this->toString() << endl;
-       this->m_cpu->setRegister(this->m_rd, this->m_imm);
+       CDat val = this->m_cpu->getRegister(this->m_rd);
+       if(this->m_s == false) {
+               if(this->m_hl == false) {
+                       val &= 0xFFFF0000;
+               }
+               else {
+                       val &= 0x0000FFFF;
+               }
+               this->m_cpu->setRegister(this->m_rd, val + this->m_imm);
+       }
+       else {
+               this->m_cpu->setRegister(this->m_rd, this->m_imm);
+       }
 }
 
 std::string Cldi::toString()