From 49789c74f95040f9d700e26d0542263da5920e7e Mon Sep 17 00:00:00 2001 From: Jared Burce Date: Tue, 9 Mar 2021 06:42:12 -0800 Subject: [PATCH] emu: show/peek debug instructions --- src/emu/i8088.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/emu/i8088.rs b/src/emu/i8088.rs index d216a65..68622a8 100644 --- a/src/emu/i8088.rs +++ b/src/emu/i8088.rs @@ -54,6 +54,16 @@ mod ops { use emu::dos; use emu::i8088::{Bus, LValue, RValue, i8088, segoff_to_addr}; + pub fn show(cpu: &mut i8088) { + println!("{:#X?}", cpu); + } + + pub fn peek(cpu: &mut i8088, bus: &mut Bus, addr: &u16) { + let addr = segoff_to_addr(cpu.ds, *addr); + let val = bus.ram[addr]; + println!("PEEK: @{:#X} = {:#X} ({})", addr, val, val); + } + pub fn call(ip: &mut u16, ss: u16, sp: &mut u16, mem: &mut [u8], addr: i16) { let target = ip.wrapping_add(addr as u16); push16(ss, sp, mem, *ip); @@ -211,6 +221,7 @@ macro_rules! step { } }; (@r16 $cookie:tt, $cpu:expr, $bus:expr, ($modrm:ident, $modrm16:tt, $modrm8:tt)) => { { + // TODO: Should these also be passed into the macro like the modrm specs? let reg = match $modrm >> 3 & 0x7 { 0 => &mut $cpu.a, 1 => &mut $cpu.c, @@ -226,6 +237,7 @@ macro_rules! step { } }; (@r8 $cookie:tt, $cpu:expr, $bus:expr, ($modrm:ident, $modrm16:tt, $modrm8:tt)) => { + // TODO: Should these also be passed into the macro like the modrm specs? match $modrm >> 3 & 0x7 { 0 => step!(@arg $cookie, &mut RegHi { reg: &mut $cpu.a } ), 1 => step!(@arg $cookie, &mut RegHi { reg: &mut $cpu.c } ), @@ -348,6 +360,8 @@ impl i8088 { loop { step!((self, bus) => opcodes: { + 0x60 => show[cpu] / 0, // Fake opcode for debugging + 0x61 => peek[cpu, bus, d16] / 0, // Fake opcode for debugging //0x8B _ => mov[r16, modrm16] / "2/12+", 0x8C: { 0x08 => mov[modrm16, reg=cs] / "2/13+", }, 0x8E: { 0x18 => mov[reg=ds, modrm16] / "2/12+", },