Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Absolute {
- const OPCODE: u8;
- const CYCLES: usize;
- const PAGE_BOUNDARY_EXTRA_CYCLES: usize = 0;
- fn exec();
- }
- trait Indirect {
- const OPCODE: u8;
- const CYCLES: usize;
- const PAGE_BOUNDARY_EXTRA_CYCLES: usize = 0;
- fn exec();
- }
- mod jmp {
- use super::{Absolute, Indirect};
- pub struct Jmp;
- impl Absolute for Jmp {
- const OPCODE: u8 = 0xa9;
- const CYCLES: usize = 3;
- fn exec() {
- println!("executing jmp_absolute: {}", <Self as Absolute>::OPCODE);
- }
- }
- impl Indirect for Jmp {
- const OPCODE: u8 = 0xb5;
- const CYCLES: usize = 5;
- fn exec() {
- println!("executing jmp_indirect: {}", <Self as Indirect>::OPCODE);
- }
- }
- }
- use jmp::Jmp;
- fn main() {
- <Jmp as Absolute>::exec();
- <Jmp as Indirect>::exec();
- }
Add Comment
Please, Sign In to add comment