added fn get string param
This commit is contained in:
parent
655bf9eab7
commit
a151bef7ef
@ -120,6 +120,24 @@ fn syscall(machine: &Machine) -> Result<MachineOk, MachineError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_string_param(addr: i64, maxlen: i64, machine: &Machine) -> Vec<char>{
|
||||||
|
let mut dest = Vec::with_capacity(maxlen as usize);
|
||||||
|
|
||||||
|
let mut i = 0;
|
||||||
|
let mut c = 1;
|
||||||
|
|
||||||
|
while c != 0 && i < maxlen {
|
||||||
|
c = machine.read_memory(1, (addr + i) as usize);
|
||||||
|
//dest.push(c as char);
|
||||||
|
dest[i] = c as char;
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dest[maxlen - 1] = '\0';
|
||||||
|
|
||||||
|
dest
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::kernel::exception::{SC_SHUTDOWN, SC_WRITE};
|
use crate::kernel::exception::{SC_SHUTDOWN, SC_WRITE};
|
||||||
|
Loading…
Reference in New Issue
Block a user