Created
April 29, 2023 11:57
-
-
Save ilopX/bdb8118f5f0d99f66f5575da32abd22b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! print_mem { | |
($ptr:expr, $address:expr) => { | |
unsafe { | |
let a_ptr: *const u32 = &$ptr; | |
let b_ptr: *const u8 = a_ptr as *const u8; | |
println!("{:#0x}", *b_ptr.offset($address)); | |
} | |
}; | |
} | |
fn main() { | |
let i: u32 = 0b10000000_11000000_11100000_11110000; | |
println!("{:#0x}", i); | |
print_mem!(i, 0); | |
print_mem!(i, 1); | |
print_mem!(i, 2); | |
print_mem!(i, 3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment