mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-10-30 12:03:54 +02:00
53 lines
1.7 KiB
Lua
53 lines
1.7 KiB
Lua
-- When the CPU is parked in the POST delay loop, dump the stack so we can see
|
|
-- the caller chain -- i.e. who passes the absurd delay count, and where the
|
|
-- count comes from.
|
|
--
|
|
-- <mame> vt1200 -rompath harness/mame/roms -video none -sound none -nothrottle \
|
|
-- -debug -debugger none -autoboot_script harness/mame/stackwalk.lua -autoboot_delay 0
|
|
--
|
|
-- TMS34010 note: SP is a *bit* address, and a 32-bit word occupies 32 bit
|
|
-- addresses, so consecutive stack words are +/- 32.
|
|
|
|
local function hex(v) return string.format("%08X", v) end
|
|
|
|
local machine = manager.machine
|
|
local cpu = machine.devices[':maincpu']
|
|
local dbg = machine.debugger
|
|
local prog = cpu.spaces['program']
|
|
local pc = cpu.state['PC']
|
|
local sp = cpu.state['SP']
|
|
|
|
if not prog or not prog.read_u32 then
|
|
print("ERROR: program space has no read_u32")
|
|
end
|
|
|
|
local TARGET = tonumber(os.getenv("WALK_PC") or "0x3FDCE400")
|
|
local SKIP = tonumber(os.getenv("WALK_SKIP") or "40")
|
|
local frames = 0
|
|
local done = false
|
|
|
|
emu.register_frame_done(function()
|
|
frames = frames + 1
|
|
if done then return end
|
|
if pc.value == TARGET and frames > SKIP then
|
|
done = true
|
|
local s = sp.value
|
|
print(string.format("=== parked at %s SP=%s frame=%d ===", hex(TARGET), hex(s), frames))
|
|
for i = -4, 28 do
|
|
local a = (s + i * 32) & 0xFFFFFFFF
|
|
local v = prog:read_u32(a)
|
|
local tag = ""
|
|
if v >= 0x3F200000 and v < 0x40000000 then
|
|
tag = string.format(" <- ROM bit addr -> file 0x%06X", (v - 0x3F200000) / 8)
|
|
elseif v < 0x00200000 then
|
|
tag = " <- low RAM bit addr"
|
|
end
|
|
print(string.format(" [%+3d] @%s = %s%s", i, hex(a), hex(v), tag))
|
|
end
|
|
machine:exit()
|
|
end
|
|
end, "vt1200-stackwalk")
|
|
|
|
dbg.visible_cpu = cpu
|
|
dbg.execution_state = 'run'
|