Find all chosen sequences of bytes in memory

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
Ralf
Rick Dangerous
Posts: 2283
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Find all chosen sequences of bytes in memory

Post by Ralf »

I have a practical problem.

Let's suppose I want to find all chosen sequences of bytes in Zx Spectrum memory.

As you may guess it is related to code debugging. I'd like to find all appearances of
instructions like LD A,(30000) OR CALL 40000 which may mean in the game losing a life, increasing the score etc.

As a result I'd like to get a list of memory addressess where my instruction appears like:

25246
37547
49232
60071

It is possible with any existing tool?
User avatar
Lethargeek
Manic Miner
Posts: 742
Joined: Wed Dec 11, 2019 6:47 am

Re: Find all chosen sequences of bytes in memory

Post by Lethargeek »

what do you mean "in memory"? a paused emulator?

for snapshots try using hexed.it
User avatar
bob_fossil
Manic Miner
Posts: 654
Joined: Mon Nov 13, 2017 6:09 pm

Re: Find all chosen sequences of bytes in memory

Post by bob_fossil »

Maybe a bit overkill for what you need but you can search for opcode sequences in the Z80 loader for Ghidra. You could save the memory out from the emulator and import it in. I've used it for disassembling and annotating esxdos commands. You can label functions and data as well.
Ralf
Rick Dangerous
Posts: 2283
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Find all chosen sequences of bytes in memory

Post by Ralf »

for snapshots try using hexed.it
I hoped for functionality built into some emulator.
Hex editors probably would work but it wouldn't be friendly. You would have to do calculations
which would convert position of some bytes in the file to their position in Spectrum memory.

Well, I have some my own dirty tools working on .sna snapshots and could add such option to one of them.
I guess it could be written in an hour or so and may be actually the easiest way for me.
User avatar
Lethargeek
Manic Miner
Posts: 742
Joined: Wed Dec 11, 2019 6:47 am

Re: Find all chosen sequences of bytes in memory

Post by Lethargeek »

or you can make a converter to extract just the memory contents from snapshots

unfortunately the original sna format was developed without considering hex editing
everything would be so much easier if it kept all the regs and other extra info at the end
(it is possible to write a 2-way converter for this however)
User avatar
Luzie
Manic Miner
Posts: 907
Joined: Fri May 01, 2020 2:07 pm

Re: Find all chosen sequences of bytes in memory

Post by Luzie »

Ralf wrote: Fri May 29, 2020 10:18 am I hoped for functionality built into some emulator.
Over the years I´ve read about some utilites which may help you. But I can´t remember them yet.

Via GOOGLE "zx spectrum poke finder"
I found this:
https://www.worldofspectrum.org/pfw/ - Poke Finder Wizard Homepage - World of Spectrum
The Poke Finder Wizard is an add-on to ZX32, a Windows 32-bit ZX Spectrum emulator by Vaggelis Kapartzianis. What the wizard will do basically is to help you ...

Fuse Emulator may have a Poke Finder: http://manpages.ubuntu.com/manpages/eoa ... e%20finder
Tutorial: https://www.benmayersohn.com/2019/01/di ... -nohzdyve/

And SpecEmu (Menu Monitor/Cheats Finder) too. I´m sure there are more and with bytes-search-abililty you asked for, but we have to look for them.
User avatar
SkoolKid
Manic Miner
Posts: 407
Joined: Wed Nov 15, 2017 3:07 pm

Re: Find all chosen sequences of bytes in memory

Post by SkoolKid »

If you have a SNA, SZX or Z80 snapshot, you could use the --find option of snapinfo.py in SkoolKit. For example:

Code: Select all

$ snapinfo.py --find 195,0,0 game.z80 # Find 'JP 0' anywhere in the snapshot
SkoolKit - disassemble a game today
Pyskool - a remake of Skool Daze and Back to Skool
Post Reply