trap: OUT
This commit is contained in:
parent
666152229a
commit
7953afdd5d
@ -289,7 +289,7 @@ fn op_trap(vm: &mut VM, instr: u16) {
|
|||||||
let trap_vector = instr & 0xff;
|
let trap_vector = instr & 0xff;
|
||||||
match trap_vector {
|
match trap_vector {
|
||||||
0x20 => trap_getc(vm),
|
0x20 => trap_getc(vm),
|
||||||
0x21 => todo!("OUT"),
|
0x21 => trap_out(vm),
|
||||||
0x22 => trap_puts(vm),
|
0x22 => trap_puts(vm),
|
||||||
0x23 => todo!("IN"),
|
0x23 => todo!("IN"),
|
||||||
0x24 => todo!("PUTSP"),
|
0x24 => todo!("PUTSP"),
|
||||||
@ -315,3 +315,11 @@ fn trap_getc(vm: &mut VM) {
|
|||||||
while vm.mem.get_mem(0xFE00) & (1 << 15) == 0 {}
|
while vm.mem.get_mem(0xFE00) & (1 << 15) == 0 {}
|
||||||
vm.registers.r0 = vm.mem.get_mem(0xFE02) & 0xFF;
|
vm.registers.r0 = vm.mem.get_mem(0xFE02) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn trap_out(vm: &mut VM) {
|
||||||
|
let val = char::from_u32((vm.registers.r0 & 0xFF).into());
|
||||||
|
match val {
|
||||||
|
Some(c) => print!("{}", c),
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user