19 February 2011, 22:09 | #1 |
2 contact me: email only!
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
|
How do you do a clean base register disassembly using Resource?
I know how most of the functions in the fantastic disassembler Resource work, but I've never worked out how to do this so hopefully someone here knows the answer!
Let's say we have some code like this: Code:
lea _BaseA5(pc),a5 move.w #0,2(a5) move.l #'FILE',12(a5) move.l #$10000,16(a5) bsr _Something move.l 16(a5),d7 rts _BaseA5 dc.w 0 dc.w 0 dc.l 0 dc.l 0 I would like all the code to change 2(a5) to numRetries(a5), 12(a5) to fileName(a5) etc so the code (everywhere) would look like so: Code:
numRetries equ 2 fileName equ 12 loadAddress equ 16 lea _BaseA5(pc),a5 move.w #0,numRetries(a5) move.l #'FILE',fileName(a5) move.l #$10000,loadAddress(a5) bsr _Something move.l loadAddress(a5),d7 rts _BaseA5 dc.w 0 dc.w 0 dc.l 0 dc.l 0 Is it possible? |
19 February 2011, 23:47 | #2 |
Moderator
Join Date: Jan 2002
Location: France
Posts: 491
|
It can be done using in menu L (Labels)/Edit single/Symbol - dest (in "Options 1", Symbols must be activated).
But the labels symbols will not be displayed on top in Resource, only when saving the asm file. |
20 February 2011, 00:19 | #3 |
2 contact me: email only!
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
|
That only seems to change the current symbol. I was hoping all references to 2(a5) in the code would change.
|
20 February 2011, 03:04 | #4 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Yes, but surely the danger with changing all references to 2(a5) is that it may change some that you don't want changing - for example when a5 contains a different address, unless the program has a way of working out what a5 contains and can compare them all and only change the relevant ones?
Personally, I use DevPac (or any text editor) and would change 2(a5) using the find & replace method. I hate seeing things like _LbC00046 in dissassembled code. It makes it much harder to understand, IMO. I was tempted to write my own dissassembler at one point, but for now I think I'll stick to just doing it by hand - which is great because I don't need to do it at all with my current project!! Regards, Lonewolf10 |
20 February 2011, 08:10 | #5 |
2 contact me: email only!
Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,182
|
Well I'm not quite sure how the "specify base register" thing actually works in that case, as if you set a register like a5 to be the base and then set it to use that base register for an address, it does seem to change all code segments throughout the program, whether a5 remains or would change later on!
Maybe it can't be done easily? |
20 February 2011, 09:45 | #6 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
There is a liboffset(a6) replacement function, but I have limited experience with that. Unless you can specify a 'stop replacing here' position, it will replace it globally. Glen McDiarmid is obviously a highly intelligent coder, so for lib calls it should be possible; for other uses it's not certain.
Basically, everything that is an offset requires intelligence and manual labor, for search/replace work like this, it's better to do it in a text editor, I think. My preference (with all of 2 programs resourced so far, haha) is to not analyze what the code does in ReSource, but to just get a working source out with as few steps as possible. Then I bring it into AsmOne and search/replace labels. Lonewolf, you could do like me and get slightly more readable code, namely search/replace _LbC000xx with Codexx, _LbC00xxx with Codexxx, _LbW000xx with Wordxx etc. (Ie. remove leading zeros and name the label after what is there, usually this gives more insight such as Wordxx label points to longword data, oops) |
20 February 2011, 12:53 | #7 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
If you can't be sure that the base register never changes throughout the program you can/should use the "Convert specific EA's" menu, there you can set the base address and then decide if you want to convert an offset or not. It's a lot of work obviously. If you only need to convert a small block of code, the "set lower/upper limit" functions might be more convenient since you can define where the conversion should start/end that way. At least ReSource allows you to change label names at will. Last edited by StingRay; 20 February 2011 at 13:09. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to make sense of disassembly? | Jonathan Drain | Coders. General | 1 | 27 October 2009 22:57 |
What do you get when you register? | Magno Boots | project.WHDLoad | 4 | 31 January 2007 12:18 |
Need a little disassembly/binary edit help | mr_a500 | Coders. General | 5 | 30 April 2006 21:33 |
Game Base 64 V2 | plasmatron | Retrogaming General Discussion | 14 | 03 September 2004 23:02 |
Base Jumpers CD³² | MethodGit | request.Old Rare Games | 4 | 22 January 2002 05:32 |
|
|