Fix SRL and SRA

This commit is contained in:
Kevin Hamacher 2016-05-29 15:13:16 +02:00
parent 4a1b335887
commit fbffa7dccb

View File

@ -209,7 +209,7 @@ impl CPU {
}
let v: u8 = self.get_8bit_reg(reg_id);
self.set_clear_flag(FLAG_C, v & 1 > 0);
self.set_8bit_reg(reg_id, v >> 1);
self.set_8bit_reg(reg_id, v >> 1 | v & 0x80);
},
0x30 ... 0x37 => {
let reg_id = (instruction - 0x30) as usize;
@ -225,8 +225,14 @@ impl CPU {
println!("SRL {}", REG_NAMES[reg_id]);
}
let v: u8 = self.get_8bit_reg(reg_id);
self.set_8bit_reg(reg_id, v << 1);
self.set_8bit_reg(reg_id, v >> 1);
self.set_clear_flag(FLAG_C, v & 1);
self.clear_flag(FLAG_N);
self.clear_flag(FLAG_H);
self.set_clear_flag(FLAG_Z, (v & 0xFE) == 0);
},
// Bits
0x40 ... 0x47 => {
// Test 0th bit
let reg_id = (instruction - 0x40) as usize;