From 398e6b6a3c7cc7efd579e00f6f65bde40e39d628 Mon Sep 17 00:00:00 2001 From: David Li Date: Sun, 20 Dec 2015 22:29:28 -0500 Subject: Try handling syscalls --- src/simulator.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/simulator.rs b/src/simulator.rs index a7140fe..8142b32 100644 --- a/src/simulator.rs +++ b/src/simulator.rs @@ -69,7 +69,7 @@ impl Simulator { pub fn run(&mut self) { let base_core = Core { - pc: 0x10000, + pc: 0x1002C, registers: RegisterFile::new(), running: true, }; @@ -273,11 +273,18 @@ impl Simulator { panic!("Invalid store funct3code: 0x{:x}", inst.funct3()); } }, - isa::opcodes::SYSTEM => { - + isa::opcodes::SYSTEM => match inst.i_imm() { + 0x0 => { + // System call + println!("System call {}:", core.registers.read_word(isa::Register::X10)); + println!("Argument {:X}:", core.registers.read_word(isa::Register::X11)); + } + _ => { + + } }, _ => { - panic!("Invalid opcode: 0x{:02X}", inst.opcode()); + panic!("Invalid opcode: 0x{:02X} at PC 0x{:X}", inst.opcode(), pc); } } } -- cgit v1.2.3