Commit 428f6716 authored by George Hotz's avatar George Hotz

movz movn

parent bf45a2ea
...@@ -24,6 +24,7 @@ contract MIPS { ...@@ -24,6 +24,7 @@ contract MIPS {
IMIPSMemory public immutable m; IMIPSMemory public immutable m;
uint32 constant public REG_OFFSET = 0xc0000000; uint32 constant public REG_OFFSET = 0xc0000000;
uint32 constant public REG_ZERO = REG_OFFSET;
uint32 constant public REG_PC = REG_OFFSET + 0x20*4; uint32 constant public REG_PC = REG_OFFSET + 0x20*4;
uint32 constant public REG_HI = REG_OFFSET + 0x21*4; uint32 constant public REG_HI = REG_OFFSET + 0x21*4;
uint32 constant public REG_LO = REG_OFFSET + 0x22*4; uint32 constant public REG_LO = REG_OFFSET + 0x22*4;
...@@ -67,7 +68,7 @@ contract MIPS { ...@@ -67,7 +68,7 @@ contract MIPS {
// decode // decode
// register fetch // register fetch
uint32 storeAddr = 0xFFFFFFFF; uint32 storeAddr = REG_ZERO;
uint32 rs; uint32 rs;
uint32 rt; uint32 rt;
if (opcode != 2 && opcode != 3) { // J-type: j and jal have no register fetch if (opcode != 2 && opcode != 3) { // J-type: j and jal have no register fetch
...@@ -169,8 +170,14 @@ contract MIPS { ...@@ -169,8 +170,14 @@ contract MIPS {
storeAddr = REG_PC; storeAddr = REG_PC;
} }
if (opcode == 0 && func == 0xa) { // movz
if (rt != 0) storeAddr = REG_ZERO;
} else if (opcode == 0 && func == 0xb) { // movn
if (rt == 0) storeAddr = REG_ZERO;
}
// write back // write back
if (storeAddr != 0xFFFFFFFF) { if (storeAddr != REG_ZERO) {
// does this ever not happen? yes, on untaken beq/bne // does this ever not happen? yes, on untaken beq/bne
stateHash = m.WriteMemory(stateHash, storeAddr, val); stateHash = m.WriteMemory(stateHash, storeAddr, val);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment