Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2011-10-12 15:31:41

Cartmic
Member
Registered: 2010-10-16
Post 77/156

Does there exist a tool to disassemble chunks of code?

Has anyone come across a Disassembler that will disassemble chunks of code separated from the ROM? I've decided much that it's a great learning experience to disassemble by hand it is taking too long, so I think a tool could help a great deal.

Offline

#2 2011-10-12 20:13:53

visionseeming
New member
Registered: 2011-07-19
Post 6/7

Re: Does there exist a tool to disassemble chunks of code?

I've used this tool a few times a while ago:  -http://nocash.emubase.de/z80.zip-.  It's okay, though I think it might mess up some opcodes that were changed from Z80 to GB, but I believe it allows you to disassemble a number of bytes starting from an offset.  Regardless, the program by no means emulates the code as it runs, so it cannot find code offsets(vs other data) or determine how long the code actually is.  Following the code paths while spitting out the assembly doesn't seem like too difficult a feature to add to an emulator with a debugger, but I don't know of any that have that feature.

Edit:  Now that I think of it, BGB and/or No$GMB have this already built in and is less glitchy, so I guess this is pretty much useless.

Last edited by visionseeming (2011-10-16 04:45:14)


"To some people, Pokemon hacks are just games. Others use them for battling/trading. Us? We study the hacks like a profession. But we don't know everything yet. There are still many mysteries left to be solved. That's why we hack Pokemon every day."--Mateo

Offline

#3 2011-10-13 18:13:54

Sawakita
Administrator
Registered: 2010-10-16
Post 213/364

Re: Does there exist a tool to disassemble chunks of code?

The problem with disassemblers is that they rarely disassemble code in the format you might need, i.e. the format compatible with the assembler you're using. I don't know about no$GMB, but BGB dumps the ASM code along with an in-line text describing the ROM bank and address, which forces you to delete that text one line per time (which is rather time consuming) if you want to use that code (BGB also doesn't put the hex prefix ('$' or '0x' or '&h') near hexadecimal numbers, if i recall correctly).
I've yet to find a disassembler that disassemble the code in RGBDS-compatible format, so I started working on my own disassembler, some time ago. Too bad, the annihilation of my free time in this last period has prevented me from actually working on it...

Offline

#4 2011-10-13 18:43:53

Tauwasser
Member
Registered: 2010-10-16
Post 208/448

Re: Does there exist a tool to disassemble chunks of code?

Just use regular expressions to clean the stuff up, if you need to.

cYa,

Tauwasser

Offline

#5 2011-10-13 23:10:13

Cartmic
Member
Registered: 2010-10-16
Post 78/156

Re: Does there exist a tool to disassemble chunks of code?

Sawakita wrote:

The problem with disassemblers is that they rarely disassemble code in the format you might need, i.e. the format compatible with the assembler you're using. I don't know about no$GMB, but BGB dumps the ASM code along with an in-line text describing the ROM bank and address, which forces you to delete that text one line per time (which is rather time consuming) if you want to use that code (BGB also doesn't put the hex prefix ('$' or '0x' or '&h') near hexadecimal numbers, if i recall correctly).
I've yet to find a disassembler that disassemble the code in RGBDS-compatible format, so I started working on my own disassembler, some time ago. Too bad, the annihilation of my free time in this last period has prevented me from actually working on it...

Cleaning up the ROM bank and address stuff isn't a problem. StrongED, a text editor I use on RISC OS, allows you to select multiple lines and edit the one line then it will do exactly the same simultaneously to ever other line you have selected.

@visionseeming

Great! Just what I need thanks.
About the data, I'll just run through it briefly and see if I can see it then split the ROM dump up even more.

Offline

#6 2011-10-14 01:09:53

292/700

Re: Does there exist a tool to disassemble chunks of code?

Tauwasser wrote:

Just use regular expressions to clean the stuff up, if you need to.

cYa,

Tauwasser

s/.*  //
s/\([0-9a-f]\{2\}\)/$\1/g
s/\([0-9a-f]\)\$/\1/g

The first one will strip out everything before the instruction on a line. It will misbehave if BGB ever puts two spaces after the instruction.

The last two prefix 8‐ and 16‐bit constants with a $. I feel like there should be a way to replace them with a single regex, but I can’t think of one at the moment.

In Vi you can prefix them with :% to apply them to all lines. (E.g., “:%s/foo/bar/”.)

#7 2011-10-16 04:41:32

visionseeming
New member
Registered: 2011-07-19
Post 7/7

Re: Does there exist a tool to disassemble chunks of code?

Cartmic wrote:

I've decided much that it's a great learning experience to disassemble by hand it is taking too long, so I think a tool could help a great deal.

Cartmic wrote:

Great! Just what I need thanks.
About the data, I'll just run through it briefly and see if I can see it then split the ROM dump up even more.

Thanks, but please don't use that z80 program I linked to.  I tried it out but it is crud since it doesn't handle the GB custom opcodes well.  It spits out many IN/OUT commands which are not even present in GB.  That being said, BGB has the feature built in, so just use that.  The only difference is that you will have to compute the length in bytes of the assembly you wish to dump, instead of specifying a start and stop address.

I'm curious though, what exactly did you mean at the beginning when you said you were doing it by hand?  Were you just working at the machine language level in a hexadecimal editor?


"To some people, Pokemon hacks are just games. Others use them for battling/trading. Us? We study the hacks like a profession. But we don't know everything yet. There are still many mysteries left to be solved. That's why we hack Pokemon every day."--Mateo

Offline

#8 2011-10-16 11:33:25

Cartmic
Member
Registered: 2010-10-16
Post 79/156

Re: Does there exist a tool to disassemble chunks of code?

@visionseeming

Yes I was.

Offline

#9 2011-10-16 11:51:32

Sawakita
Administrator
Registered: 2010-10-16
Post 214/364

Re: Does there exist a tool to disassemble chunks of code?

IIMarckus wrote:
Tauwasser wrote:

Just use regular expressions to clean the stuff up, if you need to.

cYa,

Tauwasser

s/.*  //
s/\([0-9a-f]\{2\}\)/$\1/g
s/\([0-9a-f]\)\$/\1/g

The first one will strip out everything before the instruction on a line. It will misbehave if BGB ever puts two spaces after the instruction.

The last two prefix 8‐ and 16‐bit constants with a $. I feel like there should be a way to replace them with a single regex, but I can’t think of one at the moment.

In Vi you can prefix them with :% to apply them to all lines. (E.g., “:%s/foo/bar/”.)

These certainly will come in handy, and not only for me, I believe. Thank you really.

Offline

Board footer

Powered by FluxBB