Guest User

Untitled

a guest
Jul 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. trait Absolute {
  2. const OPCODE: u8;
  3. const CYCLES: usize;
  4. const PAGE_BOUNDARY_EXTRA_CYCLES: usize = 0;
  5.  
  6. fn exec();
  7. }
  8.  
  9. trait Indirect {
  10. const OPCODE: u8;
  11. const CYCLES: usize;
  12. const PAGE_BOUNDARY_EXTRA_CYCLES: usize = 0;
  13.  
  14. fn exec();
  15. }
  16.  
  17. mod jmp {
  18. use super::{Absolute, Indirect};
  19.  
  20. pub struct Jmp;
  21.  
  22. impl Absolute for Jmp {
  23. const OPCODE: u8 = 0xa9;
  24. const CYCLES: usize = 3;
  25.  
  26. fn exec() {
  27. println!("executing jmp_absolute: {}", Absolute::OPCODE);
  28. }
  29. }
  30.  
  31. impl Indirect for Jmp {
  32. const OPCODE: u8 = 0xb5;
  33. const CYCLES: usize = 5;
  34.  
  35. fn exec() {
  36. println!("executing jmp_indirect: {}", Indirect::OPCODE);
  37. }
  38. }
  39. }
  40.  
  41. use jmp::Jmp;
  42.  
  43. fn main() {
  44. Jmp::<Absolute>::exec();
  45. // Jmp::<Indirect>::exec();
  46. }
Add Comment
Please, Sign In to add comment