English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 24 January 2020, 13:39   #1
zero
Registered User
 
Join Date: Jun 2016
Location: UK
Posts: 428
Disassembler for 68K

What is the best decompiler for 68k? I am reverse engineering the Sidewinder level format and need to look at the code.

I've only ever decompiled my own code for debugging, never anyone else's.

What's good for this?

Last edited by SpeedGeek; 09 January 2022 at 12:33. Reason: Title correction.
zero is offline  
Old 24 January 2020, 13:45   #2
Hewitson
Registered User
 
Hewitson's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,773
Decompiler? What you want is a disassembler. Resource is the most used Amiga one, but if you're using WinUAE the debugger might be worth checking out
Hewitson is offline  
Old 24 January 2020, 14:13   #3
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,174
IRA is very good and even has a windows port. IDA 68k is the best but not free
jotd is offline  
Old 24 January 2020, 19:28   #4
Leo24
Registered User
 
Join Date: May 2017
Location: Sao Paulo
Posts: 17
Ghidra is similar to IDA and runs on various platforms. Disassembles and decompiles 680x0 code from raw bins, amiga hunk, sysv elf, a.out, etc. https://ghidra-sre.org
Leo24 is offline  
Old 24 January 2020, 22:41   #5
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,174
Didn't find where ghidra can load amiga hunk format. Not without extensions it can't.
jotd is offline  
Old 25 January 2020, 12:21   #6
WayneK
Registered User
 
Join Date: May 2004
Location: Somewhere secret
Age: 50
Posts: 365
Ghidra is probably best if you don't have an IDA Pro licence (*cough*), or you could also try Radare2 (use "Cutter", recently much improved GUI for r2 - this also includes the Ghidra decompiler as a plugin).

For understanding level formats, you'll need both dynamic (WinUAE debugger) + static (tools above) analysis probably.
WayneK is offline  
Old 25 January 2020, 14:26   #7
hitchhikr
Registered User
 
Join Date: Jun 2008
Location: somewhere else
Posts: 511
I disassembled sidewinder a few years ago, grab it here:

http://franck.charlet.pagesperso-ora...p/side_src.zip

Afair, IDA have bugs regarding m68k disassembling (pc relative mode and short variables addressing mode aren't handled correctly).
hitchhikr is offline  
Old 25 January 2020, 15:48   #8
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,174
yes, IDA isn't suitable if you want to rebuild your app. IRA is much better for this.
jotd is offline  
Old 25 January 2020, 20:58   #9
redblade
Zone Friend
 
redblade's Avatar
 
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,127
I had trouble getting the text mode to work with IRA so that it would add the text into the source files.
Some times I would disassemble a binary with ReSource and then reassemble it and it would be bigger than the origional. I never had that problem with IRA, actually the binary ended up smaller.

This problem is highly likely to be me not reading the manual.
redblade is offline  
Old 25 January 2020, 21:02   #10
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,174
IRA has bugs but I've been using it a lot and it does the job. R means "reassembler"

I remember reassembling BattleChess from IRA disassembly and it worked.

It has bugs, but nothing that can't be fixed by post processing. I've already written python scripts to fix some instructions that don't work (BTST #xx,y). I've already written some code to try to recognize text in data. I can dig that up if you're interested.
jotd is offline  
Old 26 January 2020, 00:18   #11
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by redblade View Post
Some times I would disassemble a binary with ReSource and then reassemble it and it would be bigger than the origional. I never had that problem with IRA, actually the binary ended up smaller.

You're doing it wrong in both cases. The reassembled binary should have EXACTLY the same size as the original.
StingRay is offline  
Old 26 January 2020, 00:50   #12
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by redblade View Post
I had trouble getting the text mode to work with IRA so that it would add the text into the source files.
When the automatic text detection doesn‘t work then you just have to add a TEXT directive to the config file for the region in question.

Quote:
actually the binary ended up smaller.
Make sure all optimisations in the assembler are disabled. At least until you reached a perfect reassembly.
phx is offline  
Old 26 January 2020, 01:03   #13
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by jotd View Post
It has bugs, but nothing that can't be fixed by post processing.
Or by reporting them to the authors, as IRA is still under active development.

Quote:
I've already written python scripts to fix some instructions that don't work (BTST #xx,y).
Do you mean that some BTST are not recognized? BTST on memory with a bit number > 7 is ignored. You can enable that with -COMPAT=b.

Quote:
I've already written some code to try to recognize text in data. I can dig that up if you're interested.
See above. Use the TEXT directive.

Maybe I should make some tutorial how to use IRA, but I hope that it is clear that reassembly is not finished after a single run. You will constantly check the output, change the config file and regenerate. Until the output is perfect.
phx is offline  
Old 26 January 2020, 08:54   #14
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,174
I can't reproduce the BTST stuff with a simple example. But when I reversed big games with either POTGO tests or blitterwaits (using BTST.B) it sometimes issued DC.W instead.

I also can crash IRA/lock it with some exes. I have to switch to d68k which I don't like that much.

I'm using an outdated 2010 version. Will upgrade.

A tutorial would be appreciated. As much as this program is appreciated for years
jotd is offline  
Old 29 January 2020, 11:31   #15
zero
Registered User
 
Join Date: Jun 2016
Location: UK
Posts: 428
I'll try Ghidra. I guess WinUAE is going to be necessary too.

Fortunately it doesn't look too bad in that it probably just loads the level data into RAM and operates on it from the main loop of the game, so shouldn't be too hard to find with the game running.

Sadly I think the original source code for Sidewinder is long gone, which would have made this so much easier.
zero is offline  
Old 29 January 2020, 16:52   #16
hitchhikr
Registered User
 
Join Date: Jun 2008
Location: somewhere else
Posts: 511
I posted the disassembled (with Resource) source code above, perhaps you missed it ?
hitchhikr is offline  
Old 29 January 2020, 17:01   #17
zero
Registered User
 
Join Date: Jun 2016
Location: UK
Posts: 428
Quote:
Originally Posted by hitchhikr View Post
I posted the disassembled (with Resource) source code above, perhaps you missed it ?
I saw it but it needs a lot of work. Most of the symbol names are missing and even just finding the main loop isn't easy. Maybe once I have dived in with WinUAE it might be more useful.

For adding all the symbol names in it's easier to work in the disassembler I think.
zero is offline  
Old 29 January 2020, 17:17   #18
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,174
I use to find mainloops all the time for instance to find levelskips or insert CD-music play. I have a good technique with WinUAE. Let me explain.

Play the game and break with shift+F12.

First get rid of the case where you're in an interrupt with "fi RTE", then "t". Unless there's a trap within an interrupt, that should get you back in non-VBL part of the game.

Note down the value of A7. Then use "fi" instruction to find next RTS and "t" to return from it. See if A7 increases. If it doesn't, that's because the RTS is from a subroutine. So ignore that one.

After a few moments, you find the highest A7 value. Means that you're in the main loop. Put breakpoints here and there to find the point beyond which the breakpoint doesn't hit. There's probably a label, and below a BRA to it.
jotd is offline  
Old 29 January 2020, 17:25   #19
hitchhikr
Registered User
 
Join Date: Jun 2008
Location: somewhere else
Posts: 511
I realize that i didn't include the .rs (for Resource): http://franck.charlet.pagesperso-ora...mp/side_rs.zip
hitchhikr is offline  
Old 30 January 2020, 13:03   #20
WayneK
Registered User
 
Join Date: May 2004
Location: Somewhere secret
Age: 50
Posts: 365
Since the first post was about reversing the level format, if the individual levels are loaded from disk I would find the disk loader (search for writes to DFF07E/DSKSYNC, work back to find the loader entrypoint then find references to this) and breakpoint after loading to find what the game does with the loaded data (typically depack it then parse it, so it should be one of the first few subroutines called after loading).

If it doesn't load individual levels (they're all stored in RAM), use typical 'trainer techniques' to find the level counter and then find references to this for the leveldata-handling routines.
WayneK is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disassembler copse Coders. General 86 01 January 2023 20:34
Peasauce disassembler copse Coders. General 1 31 January 2021 20:54
IDA Disassembler BippyM Coders. General 36 03 October 2018 10:51
68K assembler/disassembler syntax nocash Coders. Asm / Hardware 13 23 April 2016 00:35
A good 68K disassembler TikTok request.Apps 11 23 January 2002 03:49

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:09.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09346 seconds with 14 queries