more opcodes
This commit is contained in:
parent
ca839d9375
commit
121129fe35
1 changed files with 62 additions and 6 deletions
|
@ -75,14 +75,70 @@ impl CPU {
|
||||||
self.state.hl.as_u16 += 1;
|
self.state.hl.as_u16 += 1;
|
||||||
},
|
},
|
||||||
0x23 => unsafe { self.state.hl.as_u16 += 1 },
|
0x23 => unsafe { self.state.hl.as_u16 += 1 },
|
||||||
0x2C => {
|
0x24 => unsafe { self.state.hl.as_u8s.left += 1 },
|
||||||
unsafe {
|
0x25 => unsafe { self.state.hl.as_u8s.left -= 1 },
|
||||||
self.state.hl.as_u8s.right += 1;
|
0x26 => self.state.hl.as_u8s.left = self.ld_immediate_byte(),
|
||||||
};
|
0x27 => panic!("DAA instruction: 0x27"),
|
||||||
|
0x28 => {
|
||||||
|
let jump_size = self.ld_immediate_byte();
|
||||||
|
if self.get_flag(FLAGS::Z) == 1 {
|
||||||
|
unsafe { self.state.pc.as_u16 += jump_size as u16 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
0x3E => {
|
0x29 => unsafe { self.state.hl.as_u16 *= 2 },
|
||||||
self.state.af.as_u8s.left = self.ld_immediate_byte();
|
0x2A => unsafe {
|
||||||
|
self.state.af.as_u8s.left = self.memory.get(self.state.hl.as_u16);
|
||||||
|
self.state.hl.as_u16 += 1;
|
||||||
|
},
|
||||||
|
0x2B => unsafe { self.state.hl.as_u16 -= 1 },
|
||||||
|
0x2C => unsafe { self.state.hl.as_u8s.right += 1 },
|
||||||
|
0x2D => unsafe { self.state.hl.as_u8s.right -= 1 },
|
||||||
|
0x2E => self.state.hl.as_u8s.right = self.ld_immediate_byte(),
|
||||||
|
0x2F => unsafe { self.state.af.as_u8s.left = !self.state.af.as_u8s.left },
|
||||||
|
0x30 => {
|
||||||
|
let jump_size = self.ld_immediate_byte();
|
||||||
|
if self.get_flag(FLAGS::C) == 0 {
|
||||||
|
unsafe { self.state.pc.as_u16 += jump_size as u16 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
0x31 => self.state.sp = self.ld_immediate_word(),
|
||||||
|
0x32 => unsafe {
|
||||||
|
self.memory
|
||||||
|
.set(self.state.hl.as_u16, self.state.af.as_u8s.left);
|
||||||
|
self.state.hl.as_u16 -= 1;
|
||||||
|
},
|
||||||
|
0x33 => unsafe { self.state.sp.as_u16 += 1 },
|
||||||
|
0x34 => unsafe {
|
||||||
|
let address = self.state.hl.as_u16;
|
||||||
|
let data = self.memory.get(address) + 1;
|
||||||
|
self.memory.set(address, data);
|
||||||
|
},
|
||||||
|
0x35 => unsafe {
|
||||||
|
let address = self.state.hl.as_u16;
|
||||||
|
let data = self.memory.get(address) - 1;
|
||||||
|
self.memory.set(address, data);
|
||||||
|
},
|
||||||
|
0x36 => unsafe {
|
||||||
|
let data = self.ld_immediate_byte();
|
||||||
|
self.memory.set(self.state.hl.as_u16, data);
|
||||||
|
},
|
||||||
|
0x37 => panic!("SCF instruction: 0x37 - set carry flag"),
|
||||||
|
0x38 => {
|
||||||
|
let jump_size = self.ld_immediate_byte();
|
||||||
|
if self.get_flag(FLAGS::C) == 1 {
|
||||||
|
unsafe { self.state.pc.as_u16 += jump_size as u16 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0x39 => unsafe { self.state.hl.as_u16 += self.state.sp.as_u16 },
|
||||||
|
0x3A => unsafe {
|
||||||
|
self.state.af.as_u8s.left = self.memory.get(self.state.hl.as_u16);
|
||||||
|
self.state.hl.as_u16 -= 1;
|
||||||
|
},
|
||||||
|
0x3B => unsafe { self.state.sp.as_u16 -= 1 },
|
||||||
|
0x3C => unsafe { self.state.af.as_u8s.left += 1 },
|
||||||
|
0x3D => unsafe { self.state.af.as_u8s.left -= 1 },
|
||||||
|
0x3E => self.state.af.as_u8s.left = self.ld_immediate_byte(),
|
||||||
|
0x3F => panic!("CCF instruction: 0x3F - flip carry flag"),
|
||||||
0x4A => {
|
0x4A => {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.state.bc.as_u8s.right = self.state.de.as_u8s.left;
|
self.state.bc.as_u8s.right = self.state.de.as_u8s.left;
|
||||||
|
|
Loading…
Add table
Reference in a new issue