mirror of
https://github.com/FranLMSP/snes.git
synced 2026-08-03 08:30:01 -04:00
rep
This commit is contained in:
@@ -58,6 +58,7 @@ pub mod pld;
|
|||||||
pub mod plp;
|
pub mod plp;
|
||||||
pub mod plx;
|
pub mod plx;
|
||||||
pub mod ply;
|
pub mod ply;
|
||||||
|
pub mod rep;
|
||||||
pub mod bit_common;
|
pub mod bit_common;
|
||||||
pub mod dec_common;
|
pub mod dec_common;
|
||||||
pub mod decoder_common;
|
pub mod decoder_common;
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
use crate::cpu::{bus::Bus, registers::Registers};
|
||||||
|
|
||||||
|
use crate::cpu::cycles;
|
||||||
|
use crate::utils::addressing::AddressingMode;
|
||||||
|
use super::{CPUInstruction, Decode, read_8bit_from_address};
|
||||||
|
use super::decoder_common;
|
||||||
|
|
||||||
|
static INSTR_NAME: &'static str = "REP";
|
||||||
|
|
||||||
|
pub struct REP {}
|
||||||
|
|
||||||
|
impl CPUInstruction for REP {
|
||||||
|
fn execute(&self, registers: &mut Registers, bus: &mut Bus) {
|
||||||
|
let byte = read_8bit_from_address(registers, bus, AddressingMode::Immediate);
|
||||||
|
registers.reset_rep_byte(byte);
|
||||||
|
let (bytes, cycles) = cycles::increment_cycles_rep();
|
||||||
|
registers.increment_pc(bytes); registers.cycles += cycles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Decode for REP {
|
||||||
|
fn mnemonic(&self, registers: &Registers, bus: &Bus, opcode: u8) -> String {
|
||||||
|
decoder_common::mnemonic_8bit_immediate(opcode, INSTR_NAME, registers, bus)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod cpu_instructions_tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test() {
|
||||||
|
let mut registers = Registers::new();
|
||||||
|
let mut bus = Bus::new();
|
||||||
|
registers.emulation_mode = false;
|
||||||
|
registers.pc = 0x0000;
|
||||||
|
registers.p = 0xFF;
|
||||||
|
bus.write(0x0001, 0xFF);
|
||||||
|
let instruction = REP{};
|
||||||
|
instruction.execute(&mut registers, &mut bus);
|
||||||
|
assert_eq!(registers.p, 0x00);
|
||||||
|
assert_eq!(registers.pc, 0x0002);
|
||||||
|
assert_eq!(registers.cycles, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user