Tools for inspecting z80pack core files

39 views
Skip to first unread message

Paolo Amoroso

unread,
Nov 14, 2021, 6:42:56 AM11/14/21
to
When running z80pack with the -s option, the emulator saves the machine state to the file core.z80. The simple binary format of the core file is documented by the code of the save_core()[1] function in file sim0.c of z80pack's source tree.

I wrote two Bash scripts for inspecting core files. These very simple tools are essentially wrappers around hexdump that pass the proper arguments to isolate the right parts of the file and format the output. The scripts work for me and may be a starting point for further enhancements.

The first script, z80regs, prints the values of the registers stored in a core file. Here's the source:

#!/bin/sh

# Print the Z80 register values in a z80pack core file
#
# Usage:
#
# z80regs [filename]
#
# where filename is optional and defaults to core.z80

CORE=${1:-core.z80}

hexdump $CORE -v -n 27 -e \
'1/1 "A : %02X" 1/1 " F : %02X"'\
'1/1 "\tB : %02X" 1/1 " C : %02X"'\
'1/1 "\tD : %02X" 1/1 " E : %02X"'\
'1/1 "\tH : %02X" 1/1 " L : %02X\n"'\
'1/1 "A`: %02X" 1/1 " F`: %02X"'\
'1/1 "\tB`: %02X" 1/1 " C`: %02X"'\
'1/1 "\tD`: %02X" 1/1 " E`: %02X"'\
'1/1 "\tH`: %02X" 1/1 " L`: %02X\n"'\
'1/1 "I: %02X" 1/1 "\t\tIFF: %02X" 1/1 "\t\tR: %02X\n"'\
'1/2 "PC: %04X" 1/2 "\tSP: %04X\n"'\
'1/2 "IX: %04X" 1/2 "\tIY: %04X" "\n"'

A sample run shows what the output looks like:

$ z80regs
A : 00 F : 6A B : 00 C : 00 D : 00 E : 67 H : 00 L : 61
A`: 7A F`: 00 B`: 35 C`: 67 D`: C5 E`: 00 H`: 00 L`: 00
I: 1E IFF: 19 R: 0B
PC: 713C SP: 00AB
IX: F400 IY: 0000
$

The second script, z80mem, dumps the contents of the memory stored in a core file. The source:

#!/bin/sh

# Dump the contents of memory in a z80pack core file
#
# Usage:
#
# z80mem [filename]
#
# where filename is optional and defaults to core.z80

CORE=${1:-core.z80}

hexdump $CORE -v -C -s 27

A sample run:

$ z80mem
0000001b 00 00 00 00 00 24 00 5b 05 90 8b 57 11 21 24 00 |.....$.[...W.!$.|
0000002b 0e 11 16 61 1e 7a 3e 00 b9 ca 23 00 7a 46 b8 d2 |...a.z>...#.zF..|
0000003b 1e 00 7b b8 da 1e 00 78 d6 20 77 23 0d c3 09 00 |..{....x. w#....|
[...]
0000fffb 49 e5 2d ec 06 a8 5d 03 ff 27 cc 6b 6d 14 0c ee |I.-...]..'.km...|
0001000b e7 83 32 a5 6d d0 54 fd 31 2a 95 a6 4a 8e 8d 93 |..2.m.T.1*..J...|
0001001b 73 ba 7f 7a 62 dc 7d 62 04 4a cd 71 5e |s..zb.}b.J.q^|
00010028
$


[1] https://github.com/udo-munk/z80pack/blob/master/z80core/sim0.c#L428
Reply all
Reply to author
Forward
0 new messages