TransWikia.com

Getting radare2 to load z80 binaries properly

Reverse Engineering Asked by gb_away on April 11, 2021

I’m trying to disassemble some Sega Master System roms.

In order to do so, I’ve checked for the extra 512 bytes from old roms and once I was sure they weren’t there, I proceeded to run radare2 on one of them, like so:

r2 -A somerom.sms

Radare2 correctly detects the file signature and loads it as z80 code, however when I go into visual mode, it shows the instructions as byte wide offsets (adding a lot of garbage instructions at each invalid address) but the z80 pc has 2 bytes wide steps/instructions.

My question would be: Is there a way to filter those extra addresses so the code can be displayed correctly?

I’ve tried using:

r2 -A -b 16 somerom.sms

but it doesn’t change anything.

One Answer

as i commented radare2 opens an sms file without problem if you are not using the latest version try updating radare2 or downgrading to an older version

output below isfrom 3.3.0 the last 32 bit version of radare2

:>radare2 -q -c "aa;pd 10" ak.sms
Checksum: 0x1cd0
ProductCode: 005067
Console: Sega Master System
Region: Export
RomSize: 128KB
/ (fcn) fcn.00000000 85
|   fcn.00000000 ();
|           0x00000000      f3             di
|           0x00000001      ed56           im 1
|           0x00000003      31f0df         ld sp, 0xdff0
|       ,=< 0x00000006      187d           jr 0x7d
        |   0x00000008      7b             ld a, e
        |   0x00000009      d3bf           out [0xbf], a
        |   0x0000000b      7a             ld a, d
        |   0x0000000c      d3bf           out [0xbf], a
        |   0x0000000e      c9             ret
        |   0x0000000f      ff             rst 0x38

Answered by blabb on April 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP