fixed get_string_param
This commit is contained in:
parent
8ee7470dc5
commit
586c077002
@ -176,6 +176,11 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
|
|||||||
let addr_name = machine.read_int_register(10);
|
let addr_name = machine.read_int_register(10);
|
||||||
let initial_count = machine.read_int_register((11));
|
let initial_count = machine.read_int_register((11));
|
||||||
let size = get_length_param(addr_name as usize, machine);
|
let size = get_length_param(addr_name as usize, machine);
|
||||||
|
let name = get_string_param(addr_name, size, machine);
|
||||||
|
|
||||||
|
if initial_count <0{
|
||||||
|
|
||||||
|
}
|
||||||
Ok(MachineOk::Ok)
|
Ok(MachineOk::Ok)
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -213,16 +218,16 @@ fn get_length_param(addr: usize, machine: & Machine) -> usize{
|
|||||||
i + 1
|
i + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_string_param(addr: i64, maxlen: i64, machine: &Machine) -> Vec<char>{
|
fn get_string_param(addr: i64, maxlen: usize, machine: &Machine) -> Vec<char>{
|
||||||
let mut dest = Vec::with_capacity(maxlen as usize);
|
let mut dest = Vec::with_capacity(maxlen);
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i: usize = 0;
|
||||||
let mut c = 1;
|
let mut c = 1;
|
||||||
|
|
||||||
while c != 0 && i < maxlen {
|
while c != 0 && i < maxlen {
|
||||||
c = machine.read_memory(1, (addr + i) as usize);
|
c = machine.read_memory(1, addr as usize + i);
|
||||||
//dest.push(c as char);
|
//dest.push(c as char);
|
||||||
dest[i] = c as char;
|
dest[i] = c as u8 as char;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user