18 January 2016, 01:17 | #1 |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 608
|
Resource tips
You can refer to a label at a resource address as '\e0$2A890\e' in, for instance, the symbol entry text field you get when you press 'v'. And let's say $2A890 is in A5, and you have an offset you want to handle (e.g. $2000 or -$184). First you need to go to the address the offset corresponds to, and make a label - it doesn't matter what. Then you can refer to the address for the offset and have it automatically pick up the label, and therefore any changes to the label. But it doesn't appear to work unless both addresses have labels.
e.g. $2000(A5) where A5 = $2A890 (with label JTD1_02A890).
Now you can change these label names at will, and they will be dynamically updated. This is useful when the program doesn't follow the C model of using the same address register globally, which the more general Convert (xx,An) EA functionality would be useful for. This can be used in data statements, as well as for operand symbols, as well as generally pretty much everything up to and including comments. While the 0 refers to labels, you can use other numbers to refer to symbols and comments. |
18 January 2016, 21:40 | #2 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,349
|
A similar thing can be achieved like this:
If A5 (say) is pointing to SomeLabel and code references offsets relative to that, e.g. move.l ($1234,A5),D0 Move to SomeLabel and press Ctrl-Shift-Alt-1. Move back to the move.l ($1234,A5),D0 instruction. Press Ctrl-1. That should create a label at SomeLabel+$1234 and replace the $1234 in the instruction disassembly with (LabelName-SomeLabel,A5). That technique is useful for jump tables too. You can have three base addresses defined and convert instructions with a different base address (e.g. Ctrl-Shift-Alt-2 and Ctrl-2 set and convert with the second base address). The key presses are equivalent to the *⇒Convert specific EA's⇒Set base #X and *⇒Convert specific EA's⇒Cvert W/base X menu items. Last edited by mark_k; 18 January 2016 at 21:50. |
18 January 2016, 23:15 | #3 | |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 608
|
Hmm, I have a suspicion the macro I wrote to do the above, has been made obsolete by your suggestion. It was quite painstaking, especially since this seems to be a buggy part of Resource v6.06 where it will get itself into states where things don't work in the macro authoring, which work outside of it.
Ouch. Just tested it. It does exactly the same if it creates labels, which I assume it does. Quote:
|
|
19 January 2016, 21:37 | #4 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,349
|
That's quite a complex macro! I never really did much with ReSource macros, apart from automating tedious/repeated things (no conditional/advanced stuff). Maybe developing that macro was a good learning experience, even if you were reinventing the wheel a bit!
Some more comments about the set/convert w/base feature... You can have up to three bases set at a time. It's not three fixed bases per disassembly though, just three currently-set bases that you can convert with. So if you set base 1 and convert a jump table, later on you can set base 1 to the address of another jump table and convert that too, without the first jump table disassembly getting altered/messed up. A technique I like to use when disassembling stuff is to add a BSS hunk to the executable before loading it into ReSource. (Maybe I mentioned that in another thread a while ago?) I use space in the BSS hunk to define structures which the program code uses, then the convert w/base feature to convert structure offsets in the code to something more readable. (I prefer doing that to using a custom symbol base, since in some cases you add structure field names as you proceed with the disassembly, and it's much easier to do that that repeatedly modify/reassemble/reload a custom symbol base.) For example, let's say a program uses a NewWindow structure. Somewhere in the dummy BSS hunk I might have a label NewWindow. [Okay not a good name for an example, this is mainly for non-standard structures.] If the code does move.w #123,(2,A0) when A0 points to a NewWindow struct, I'd convert that reference (Ctrl-Shift-Alt-1 at NewWindow label then Ctrl-1) to read move.w #123,(lbWxxxxxx-NewWindow,A0) then rename the auto-generated label to TopEdge, so the disassembly would become move.w #123,(TopEdge-NewWindow,A0). If later on you rename any of the structure field names, renaming the label will cause all mentions in the disassembly to change to the new name. A more concrete example. If you're disassembling a SCSI device driver, the driver code might use references relative to its library base, and also to its private unit structure. You could set base 1 to be the library base (label in dummy BSS hunk), and base 2 to be the unit structure (another label in dummy BSS). Then go through the code doing Ctrl-1 and Ctrl-2 where appropriate. [I hope that made some kind of sense..?] Last edited by mark_k; 19 January 2016 at 22:28. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Soldering tips | Viserion | support.Hardware | 30 | 26 July 2013 15:54 |
Want some A2000 tips 'n tricks! | 8bitbubsy | support.Hardware | 15 | 24 February 2011 04:30 |
Amberstar general tips | Rixa | Retrogaming General Discussion | 1 | 28 August 2010 23:21 |
Searching magazine tips? | Digideus | AMR contributions | 4 | 12 March 2008 00:24 |
..game tips?! | poppe | Retrogaming General Discussion | 4 | 28 March 2002 20:47 |
|
|