Advertisement
marmistrz

Untitled

Jul 7th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.16 KB | None | 0 0
  1. #[cfg(target_arch = "x86_64")]
  2. // We're going to export it anyway
  3. #[allow(dead_code)]
  4. #[allow(non_camel_case_types)]
  5. pub enum Register {
  6.     R15,
  7.     R14,
  8.     R13,
  9.     R12,
  10.     RBP,
  11.     RBX,
  12.     R11,
  13.     R10,
  14.     R9,
  15.     R8,
  16.     RAX,
  17.     RCX,
  18.     RDX,
  19.     RSI,
  20.     RDI,
  21.     ORIG_RAX,
  22.     RIP,
  23.     CS,
  24.     EFLAGS,
  25.     RSP,
  26.     SS,
  27.     FS_BASE,
  28.     GS_BASE,
  29.     DS,
  30.     ES,
  31.     FS,
  32.     GS,
  33. }
  34.  
  35. #[cfg(target_arch = "x86_64")]
  36. fn reg_num(reg: Register) -> u16 {
  37.     use self::Register::*;
  38.     match reg {
  39.         R15 => 0 * 8,
  40.         R14 => 1 * 8,
  41.         R13 => 2 * 8,
  42.         R12 => 3 * 8,
  43.         RBP => 4 * 8,
  44.         RBX => 5 * 8,
  45.         R11 => 6 * 8,
  46.         R10 => 7 * 8,
  47.         R9 => 8 * 8,
  48.         R8 => 9 * 8,
  49.         RAX => 10 * 8,
  50.         RCX => 11 * 8,
  51.         RDX => 12 * 8,
  52.         RSI => 13 * 8,
  53.         RDI => 14 * 8,
  54.         ORIG_RAX => 15 * 8,
  55.         RIP => 16 * 8,
  56.         CS => 17 * 8,
  57.         EFLAGS => 18 * 8,
  58.         RSP => 19 * 8,
  59.         SS => 20 * 8,
  60.         FS_BASE => 21 * 8,
  61.         GS_BASE => 22 * 8,
  62.         DS => 23 * 8,
  63.         ES => 24 * 8,
  64.         FS => 25 * 8,
  65.         GS => 26 * 8,
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement