English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 03 February 2012, 10:58   #1
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
question on resourcing relative addressing

Hi,
This is not a programming question. It's a question about the easiest solution for a (in my eyes) quite common problem in disassembling.

I have a program file here that I want to re-source (with ReSource). As usual, the program allocates a memory block for its global data and stores the pointer in a5. Data is addressed relatively to a5, for example:
Code:
...
jsr OpenMainWindow
move.l a0,$4(a5)
...
move.l $4(a5),a0
jsr CloseMainWindow
...
(and a lot of other references to other global data fields)
...
How can I tell ReSource to show all accesses to $4(a5) as MainWindow(a5)? (of course, without replacing other occurances of the number $4 in the code!).
If a5 pointed to a location inside the code, it would be easy. Just use the builtin functionalities of Resource for base addresses (in the "*" menu). But a5's location is not known, so I cannot set the base address. Can I have something similar for my case?
I have taken a look at the documentation about custom symbol bases, but this seems to be quite cumbersome because my knowledge about the structure of the global data continuously changes when reading the code.
ara is offline  
Old 03 February 2012, 12:18   #2
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
Defining your own symbol base could be the best option. But with that, you'd need to manually change each (xxx,a5) reference. (That wouldn't necessarily be very hard, you could use a macro to automate it.)

A hack/workaround would be to add a BSS hunk to the program executable. The BSS hunk size would be at least the size of the data A5 points to. Then you can tell ReSource to use A5 as base register with origin at the start of the BSS hunk.
mark_k is offline  
Old 03 February 2012, 12:23   #3
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
Quote:
A hack/workaround would be to add a BSS hunk
Yes, I had exactly the same idea a few seconds ago :-) Is there a way/tool to do that in ReSource? Or do I have to save it as "asm", modify the source code, assemble it and reload it into ReSource?
ara is offline  
Old 03 February 2012, 18:16   #4
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
Quote:
Is there a way/tool to do that in ReSource?
Problem solved with a hex editor :-)
ara is offline  
Old 03 February 2012, 20:34   #5
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
Good work. Probably the easiest way to modify the executable for that would be to increase the length of one of its hunks (which is stored near the start of the file). Though perhaps neater/clearer would be to actually add a separate hunk (as opposed to making a BSS area at the end of a code or data hunk). That would require a little more hacking with the hex editor since you'd need to add the new hunk header etc.
mark_k is offline  
Old 04 February 2012, 23:42   #6
ara
Registered User
 
Join Date: Oct 2009
Location: Belgium
Age: 50
Posts: 42
Quote:
Originally Posted by mark_k View Post
Though perhaps neater/clearer would be to actually add a separate hunk.
That's what I did. Fortunately, the Amiga exe format is quite simple: just adding an entry, no need to recalculate any offsets, etc.
ara 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
Trying to have portable configuration, relative paths relative to C:\Public\... ? Turrican support.WinUAE 3 24 June 2011 16:33
Memory addressing CmdrVimes Coders. General 7 25 October 2010 22:20
Relative paths Toni Wilen request.UAE Wishlist 0 16 August 2009 16:06
Memory Addressing Architecture Zetr0 support.Hardware 2 10 July 2007 16:55
Addressing modes BippyM Coders. General 17 03 February 2005 09:57

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 10:31.

Top

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