Fix endianness issues particulary with strings

This commit is contained in:
Quentin Legot
2023-05-07 14:50:41 +02:00
parent 5f8965b94d
commit 5000c28b97
3 changed files with 13 additions and 4 deletions

View File

@ -154,13 +154,17 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
let f = machine.read_int_register(12);
// load buffer
let mut buffer = "".to_string();
let mut buffer = String::new();
let mut val: [u8; 4] = [0; 4];
for (j, elem) in val.iter_mut().enumerate() {
*elem = machine.read_memory(1, address as usize + j) as u8;
}
for i in 0..size {
buffer.push((machine.read_memory(1, (address + i) as usize)) as u8 as char);
}
if f as u8 == CONSOLE_OUTPUT {
println!("{}", buffer); // todo replace with console driver in the future
print!("{}", buffer); // todo replace with console driver in the future
Ok(MachineOk::Ok)
} else {
Err("SC_WRITE to file is not yet implemented")?