forked from AbleOS/ableos
Peek and poke works
This commit is contained in:
parent
c613e5eb1a
commit
ddfbd579e3
|
@ -89,15 +89,16 @@ pub fn set_hostname(name: String) {
|
|||
}
|
||||
|
||||
/// Examine a memory pointer
|
||||
pub fn peek_memory(ptr: i64) -> u8 {
|
||||
let ptr: usize = ptr.unsigned_abs() as _;
|
||||
pub fn peek_memory(ptr: i64) -> i64 {
|
||||
println!(">:(");
|
||||
unsafe { *(ptr as *const u8) }
|
||||
unsafe { *(ptr as *const u8) as _ }
|
||||
}
|
||||
|
||||
pub fn poke_memory(ptr: i64, val: u8) {
|
||||
let ptr: usize = ptr.unsigned_abs() as _;
|
||||
unsafe { *(ptr as *mut u8) = val }
|
||||
pub fn poke_memory(ptr: i64, val: i64) {
|
||||
match val.try_into() {
|
||||
Ok(val) => unsafe { *(ptr as *mut u8) = val },
|
||||
Err(_) => println!("Error: {val} cannot be converted into u8"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ls() {
|
||||
|
|
Loading…
Reference in a new issue