Skip to content

Commit

Permalink
Cargo fmt fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier-varez committed Jan 14, 2024
1 parent b5ec1be commit 177f923
Showing 1 changed file with 45 additions and 21 deletions.
66 changes: 45 additions & 21 deletions src/dynamic_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,11 @@ impl<'a, T: MemoryInterface + 'a> Compiler<'a, T> {

fn emit_addr_mode_absolute(&mut self, instruction: &mos6502::Instruction) {
let mos6502::addressing_modes::Operand::U16(value) = instruction.operand else {
panic!("Unexpected operand type {:?} for AddressingMode::Absolute", instruction.operand);
};
panic!(
"Unexpected operand type {:?} for AddressingMode::Absolute",
instruction.operand
);
};

self.opcode_stream.push_opcode(
arm_asm::Movz::new(DECODED_OP_REGISTER)
Expand All @@ -342,8 +345,11 @@ impl<'a, T: MemoryInterface + 'a> Compiler<'a, T> {
index_reg: arm_asm::Register,
) {
let mos6502::addressing_modes::Operand::U16(value) = instruction.operand else {
panic!("Unexpected operand type {:?} for AddressingMode::AbsoluteIndexed", instruction.operand);
};
panic!(
"Unexpected operand type {:?} for AddressingMode::AbsoluteIndexed",
instruction.operand
);
};

self.opcode_stream.push_opcode(
arm_asm::Movz::new(SCRATCH_REGISTER)
Expand All @@ -359,11 +365,11 @@ impl<'a, T: MemoryInterface + 'a> Compiler<'a, T> {

fn emit_addr_mode_immediate(&mut self, instruction: &mos6502::Instruction) {
let mos6502::addressing_modes::Operand::U8(value) = instruction.operand else {
panic!(
"Unexpected operand {:?} for AddressingMode::Immediate",
instruction.operand
)
};
panic!(
"Unexpected operand {:?} for AddressingMode::Immediate",
instruction.operand
)
};

self.opcode_stream.push_opcode(
arm_asm::Movz::new(DECODED_OP_REGISTER)
Expand All @@ -374,16 +380,22 @@ impl<'a, T: MemoryInterface + 'a> Compiler<'a, T> {

fn emit_addr_mode_indirect(&mut self, instruction: &mos6502::Instruction) {
let mos6502::addressing_modes::Operand::U16(value) = instruction.operand else {
panic!("Unexpected operand type {:?} for AddressingMode::Indirect", instruction.operand);
};
panic!(
"Unexpected operand type {:?} for AddressingMode::Indirect",
instruction.operand
);
};

self.emit_16_byte_load_immediate_addr(DECODED_OP_REGISTER, value);
}

fn emit_addr_mode_x_indexed_indirect(&mut self, instruction: &mos6502::Instruction) {
let mos6502::addressing_modes::Operand::U8(value) = instruction.operand else {
panic!("Unexpected operand type {:?} for AddressingMode::XIndexedIndirect", instruction.operand);
};
panic!(
"Unexpected operand type {:?} for AddressingMode::XIndexedIndirect",
instruction.operand
);
};

// (u8 operand + x reg) => addr in zero page => contains the address we want
// building the address here is kinda painful because the 6502 wraps around on the
Expand Down Expand Up @@ -427,8 +439,11 @@ impl<'a, T: MemoryInterface + 'a> Compiler<'a, T> {

fn emit_addr_mode_indirect_y_indexed(&mut self, instruction: &mos6502::Instruction) {
let mos6502::addressing_modes::Operand::U8(value) = instruction.operand else {
panic!("Unexpected operand type {:?} for AddressingMode::IndirectYIndexed", instruction.operand);
};
panic!(
"Unexpected operand type {:?} for AddressingMode::IndirectYIndexed",
instruction.operand
);
};

// (u8 operand) => addr in zero page + y reg => the address we want
if value == u8::MAX {
Expand All @@ -453,8 +468,11 @@ impl<'a, T: MemoryInterface + 'a> Compiler<'a, T> {

fn emit_addr_mode_relative(&mut self, instruction: &mos6502::Instruction) {
let mos6502::addressing_modes::Operand::U8(value) = instruction.operand else {
panic!("Unexpected operand type {:?} for AddressingMode::Relative", instruction.operand);
};
panic!(
"Unexpected operand type {:?} for AddressingMode::Relative",
instruction.operand
);
};

self.opcode_stream.push_opcode(
arm_asm::Movz::new(DECODED_OP_REGISTER)
Expand Down Expand Up @@ -485,8 +503,11 @@ impl<'a, T: MemoryInterface + 'a> Compiler<'a, T> {

fn emit_addr_mode_zeropage(&mut self, instruction: &mos6502::Instruction) {
let mos6502::addressing_modes::Operand::U8(value) = instruction.operand else {
panic!("Unexpected operand type {:?} for AddressingMode::Zeropage", instruction.operand);
};
panic!(
"Unexpected operand type {:?} for AddressingMode::Zeropage",
instruction.operand
);
};

self.opcode_stream.push_opcode(
arm_asm::Movz::new(DECODED_OP_REGISTER)
Expand All @@ -501,8 +522,11 @@ impl<'a, T: MemoryInterface + 'a> Compiler<'a, T> {
index_reg: arm_asm::Register,
) {
let mos6502::addressing_modes::Operand::U8(value) = instruction.operand else {
panic!("Unexpected operand type {:?} for AddressingMode::ZeropageIndexed", instruction.operand);
};
panic!(
"Unexpected operand type {:?} for AddressingMode::ZeropageIndexed",
instruction.operand
);
};

self.opcode_stream.push_opcode(
arm_asm::Add::new(DECODED_OP_REGISTER, index_reg)
Expand Down

0 comments on commit 177f923

Please sign in to comment.