diff options
author | iximeow <me@iximeow.net> | 2021-07-03 16:18:28 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2021-07-03 16:18:28 -0700 |
commit | 3a1de246641e14e51dc138120d67842448c2bf21 (patch) | |
tree | 0702a788bf16db67b0559aa49f44604564dd9ebb /src/lib.rs | |
parent | 282645e18ac920b2c1051a0bdf3e3236ee5839d6 (diff) |
factor out MemoryAccessSize
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -18,3 +18,31 @@ pub use protected_mode::Arch as x86_32; mod real_mode; pub use real_mode::Arch as x86_16; + +const MEM_SIZE_STRINGS: [&'static str; 64] = [ + "byte", "word", "BUG", "dword", "far", "ptr", "BUG", "qword", + "far", "mword", "BUG", "BUG", "BUG", "BUG", "BUG", "xmmword", + "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", + "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "ymmword", + "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", + "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", + "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", + "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "ptr", "zmmword", +]; + +pub struct MemoryAccessSize { + size: u8, +} +impl MemoryAccessSize { + pub fn bytes_size(&self) -> Option<u8> { + if self.size == 63 { + None + } else { + Some(self.size) + } + } + + pub fn size_name(&self) -> &'static str { + MEM_SIZE_STRINGS[self.size as usize - 1] + } +} |