English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 20 September 2009, 12:46   #1
absence
Registered User
 
Join Date: Mar 2009
Location: moon
Posts: 373
Disassembling and reassembling

I'm considering trying to port an Amiga game into cross-platform C(++?) by disassembling it. I'm thinking that the best way to ensure accuracy would be to make sure I can reassemble the code and run it, and then gradually replace the game logic with C code on the Amiga (or C++ if there is a decent compiler), so I can test that it's still working as it should. Eventually I'd take the C/C++ code to the PC and replace the remaining hardware specific stuff with cross-platform (SDL or something) code and clean everything up.

Problem is, while I've done a fair share of coding, debugging, and disassembling, not much of it has been on the Amiga. I can write basic stuff in Seka-like assemblers, debug/disassemble at runtime in Action Replay or WinUAE (enough to crack basic custom disk format copy protection), but I don't know what tools are necessary to disassemble a binary blob into "source" code, assemble it into an object, compile C/C++ that calls the asm code into an object, and link the two into an executable.

I'd prefer to be able to run it from the OS even though it's a non-dos game that bangs the hardware directly. The easy way is probably to just kill the OS and reboot when I'm done testing. Does anyone have a few pointers to what tools I need, and perhaps the few lines of code that will kill the OS and let me have all the memory and other hardware for myself? You can also call me insane if you like, but I already know that.
absence is offline  
Old 20 September 2009, 13:00   #2
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
As for disassembling, either use ReSource on the Amiga (I've uploaded it for you here) or IDA Pro on the PC. I still prefer ReSource for Amiga stuff.

Attached is my mini-startup which just lets you bang the hardware (give it to her, hard ;D) in an easy way. Just include the startup and have a routine called "MAIN" in your source, this is the routine the code calls after disabling the system and stuff. Hope it helps.
Attached Files
File Type: txt startup.i.txt (5.4 KB, 226 views)
StingRay is offline  
Old 20 September 2009, 14:14   #3
absence
Registered User
 
Join Date: Mar 2009
Location: moon
Posts: 373
Quote:
Originally Posted by StingRay View Post
As for disassembling, either use ReSource on the Amiga (I've uploaded it for you here) or IDA Pro on the PC. I still prefer ReSource for Amiga stuff.
I've had a quick look at the manual, and it looks amazing. Thanks! This about the "new" syntax, will I need a particular assembler to reassemble? Also, is there a commonly supported object format that most assemblers and C compilers use?

As for a C compiler, there's GCC on Aminet, but I suppose it uses COFF and may not be compatible. Are there any other old compilers that will do the trick?

Quote:
Originally Posted by StingRay View Post
Attached is my mini-startup which just lets you bang the hardware (give it to her, hard ;D) in an easy way. Just include the startup and have a routine called "MAIN" in your source, this is the routine the code calls after disabling the system and stuff. Hope it helps.
Thanks! It looks like the startup code can restore the system afterwards, but if I don't need that, is it OK to never return from MAIN and just overwrite the data area, or will that cause problems somehow?
absence is offline  
Old 20 September 2009, 18:20   #4
Shadowfire
Registered User
 
Shadowfire's Avatar
 
Join Date: Aug 2001
Location: Connecticut USA
Posts: 617
When motorola introduced the 68020(?) processor, it had a ton of new addressing modes. The new syntax changes around some of the old ways of doing things. For instance, to move Execbase into d6, under the "old" syntax it looks like this:
Code:
   move.l 4,d6
Whereas under the new syntax, the same function looks like this:
Code:
   move.l (4),d6
In the new syntax, it is obvious that you are using indirection on your access to memory location 4 (whereas it is just implied on old syntax). This was done so that all of the addressing modes showed consistently what the operand was actually doing.

You would need to check assembler documentation to see if it supports New syntax. I know that Macro68 by default supports both syntaxes and has a directive to only support new syntax. YMMV with other asemblers.

Most assemblers support the standard amiga linker format, which ALINK or BLINK can use to link & produce an executable.

They can also produce a standalone executable directly, but you won't be able to use any external cross-references or linker libraries, since you are skipping the linker step.
Shadowfire is offline  
Old 20 September 2009, 22:21   #5
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
As for C compilers I know that vbcc is fully ISO C89 compliant and portable, and binaries for AmigaOS are readily available. The 68K back end is not fully mature, but fully functional.
Leffmann is offline  
Old 21 September 2009, 16:11   #6
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
Quote:
Originally Posted by absence View Post
Thanks! It looks like the startup code can restore the system afterwards, but if I don't need that, is it OK to never return from MAIN and just overwrite the data area, or will that cause problems somehow?
I haven't looked at that particular startup code, but if it kills the system completely, and there is no need to restore the system, then you can do anything you want, including overwriting the system areas. However, the system must be killed completely.
Thorham is offline  
Old 22 September 2009, 00:11   #7
absence
Registered User
 
Join Date: Mar 2009
Location: moon
Posts: 373
I've been playing around a bit with Resource and have gotten quite comfortable with adding symbols. However, there are of course game specific structs in there, and I can't get the user symbol feature to work. I've tried copying the example in usersymbols.doc, both with and without the macro definitions, but all that happens when I load it is that the screen flashes. I assume this means "error, you are dumb" or something, but there's no message explaining what's wrong. Here's the code:
Code:
        dc.l          levelinfoname
        dc.b          BYTESYM
        ByteSymbol    <LI_size>,6
        ByteSymbol    <LI_name>,10
        ByteSymbol    <LI_description>,38
        ByteSymbol    <LI_extradata>,42
        dc.b          ENDBASE
levelinfoname
        dc.b          'Level info',0
        cnop          0,2
Anyone know what I'm doing wrong?
absence is offline  
Old 22 September 2009, 15:30   #8
absence
Registered User
 
Join Date: Mar 2009
Location: moon
Posts: 373
Quote:
Originally Posted by absence View Post
Anyone know what I'm doing wrong?
Oh, never mind. I sort of "forgot" to assemble it. It's working now.
absence 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
Disassembling an A600 Revival9001 support.Hardware 2 31 January 2017 07:01
Disassembling resource copse Coders. General 1 02 April 2012 03:36
Disassembling games for fun crabfists Coders. General 69 29 October 2008 11:20
Still having problems reassembling A1200 Techx support.Hardware 1 12 May 2008 05:13
Reassembling - FRONTIER OSH Coders. General 8 23 December 2005 07:59

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 07:27.

Top

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