diff --git a/src/kernel/exception.rs b/src/kernel/exception.rs index 24555fe..978cec6 100644 --- a/src/kernel/exception.rs +++ b/src/kernel/exception.rs @@ -120,6 +120,24 @@ fn syscall(machine: &Machine) -> Result { } } +fn get_string_param(addr: i64, maxlen: i64, machine: &Machine) -> Vec{ + 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)] mod test { use crate::kernel::exception::{SC_SHUTDOWN, SC_WRITE};