diff options
author | Oxore <oxore@protonmail.com> | 2019-11-19 01:38:14 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2019-11-19 01:38:14 +0300 |
commit | 1cbcbb5e2912c59b9c176dfd46e863e2bee045e1 (patch) | |
tree | 1df87343a9509fcac8de6765ee34cff299a4df13 /src | |
parent | 2376146fe9ceee4429b77c4364eaf52ce57dd80c (diff) |
Implement getter for PC in Core, print offset for each instruction
Diffstat (limited to 'src')
-rw-r--r-- | src/core.rs | 5 | ||||
-rw-r--r-- | src/main.rs | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/core.rs b/src/core.rs index 1ec7bae..a3b4541 100644 --- a/src/core.rs +++ b/src/core.rs @@ -328,6 +328,11 @@ impl Core { self.pc } + /// Get current Program Counter value + pub fn pc(&self) -> u16 { + self.pc + } + /// Get current instruction pub fn op(&self) -> Op { let op = IncompleteOp::from_u8(self.rom.array[self.pc as usize]); diff --git a/src/main.rs b/src/main.rs index 8eb1648..87dd041 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use self::core::Core; fn core_worker(mut core: Core, should_stop: &Mutex<bool>, cvar: &Condvar) { loop { while !(*should_stop.lock().unwrap()) { - println!("{}", core.op()); + println!("0x{:08x}: {}", core.pc(), core.op()); core.step(); sleep(time::Duration::from_millis(1000)); } |