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
|
/// Examine a memory pointer
|
||||||
pub fn peek_memory(ptr: i64) -> u8 {
|
pub fn peek_memory(ptr: i64) -> i64 {
|
||||||
let ptr: usize = ptr.unsigned_abs() as _;
|
|
||||||
println!(">:(");
|
println!(">:(");
|
||||||
unsafe { *(ptr as *const u8) }
|
unsafe { *(ptr as *const u8) as _ }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poke_memory(ptr: i64, val: u8) {
|
pub fn poke_memory(ptr: i64, val: i64) {
|
||||||
let ptr: usize = ptr.unsigned_abs() as _;
|
match val.try_into() {
|
||||||
unsafe { *(ptr as *mut u8) = val }
|
Ok(val) => unsafe { *(ptr as *mut u8) = val },
|
||||||
|
Err(_) => println!("Error: {val} cannot be converted into u8"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ls() {
|
pub fn ls() {
|
||||||
|
|
Loading…
Reference in a new issue