English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 10 April 2015, 14:32   #1
selco
Registered User
 
Join Date: Aug 2013
Location: Germany
Posts: 81
User Symbols in ReSource

Hi,
has anybody ever tried to create/use user symbols in ReSource?

I am diasassembling and stumple about a big structure.
The code allocates some kbytes of memory and stores the address to A5.

It writes values to that alloated memory, for instance
move.l d0, (8,A5) ; d0 contains execbase ptr
...
move.l d0,(A5) ; d0 contains gfxbase
...
LEA ($30,A5),A1
JSR (_LVOInitView,A6) ; ok, ($30,A5) is struct view

Now with this knowledge I would like to build a structure definition that I can use in ReSource.

I read UserSymbols.doc but that leaves many questions open.
Do I create an Ascii-File for Resource or do I need to assemble it?
Do I need Byte- or Word-symbols?

Can anybody tell me what to do?

regards selco
selco is offline  
Old 10 April 2015, 19:25   #2
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,344
You create an ASCII source file then assemble it to an executable using an assembler (e.g. PhxAss). For your structure, assuming it's shorter than 64KB you can use the WordSymbol macro to define the field names/offsets.

As an alternative, you could add a BSS hunk to the executable you want to disassemble before loading it into ReSource. Then define a copy of the structure in the BSS data and convert A5-relative references.So you'd have
Code:
            move.l  D0,(8,A5)
            [rest of original code]

            SECTION whatever,BSS
A5struct    ds.b   $1000  ;If 4KB is enough for whatever structures you define
Then you can put your structure definition at the start of the BSS hunk. Just create a label there, A5struct or whatever. With the current position at A5struct, press Ctrl-Shift-Alt-1. That's the default key binding for SPECIAL FUNCTIONS/Convert specific EA's/Set base #1. Move to the move.l D0,(8,A5) line and press Ctrl-1 (SPECIAL FUNCTIONS/Convert specific EA's/Cvert W/base 1). That creates a label, replacing (8,A5) with (label-A5struct,A5). You can then rename that label to something meaningful.

You can have three structures like that defined (Ctrl-Shift-Alt-1/2/3) and press Ctrl-1/2/3 to convert references to each.

The advantage of that approach is, it's quicker if you're figuring out all the structure fields as you go. Whereas with a symbol base you'd need to edit and reassemble it, then load it into ReSource again whenever you make a change. And if you change the name of a structure field, all references to that field would automatically change to show the new name, unlike using a symbol base.
mark_k is offline  
Old 11 April 2015, 18:31   #3
selco
Registered User
 
Join Date: Aug 2013
Location: Germany
Posts: 81
Hello and thank you very much for your answer!

Quote:
You create an ASCII source file then assemble it to an executable using an assembler (e.g. PhxAss). For your structure, assuming it's shorter than 64KB you can use the WordSymbol macro to define the field names/offsets.
OK. That means the user symbols are mainly for new, but known/published structures, libraries etc? For instance cybergraphics.library?
Are such user-symbols available somewhere already?

Quote:
As an alternative, you could add a BSS hunk to the executable you want to disassemble before loading it into ReSource. Then define a copy of the structure in the BSS data and convert A5-relative references.
How would I do that? (Adding a BSS hunk)
Can I do that after starting disassembling with ReSource? I do not know in advance if/how many/how big strctures I will find in the code...?
Does that mean I add additional dummy variables to the code? How can I get rid of these variables later?

Actually I disassemble some Kickstart modules. (Romboot/Strap) I used remus/romsplit to split my kickstart. Then I converted "romboot" with the tool "hunk" (Aminet) because ReSource did not like Reloc32Short. Then I loaded it into Resource and started.

regards selco
selco is offline  
Old 11 April 2015, 21:26   #4
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,344
Quote:
Originally Posted by selco View Post
OK. That means the user symbols are mainly for new, but known/published structures, libraries etc? For instance cybergraphics.library?
Are such user-symbols available somewhere already?
I'm not sure. It would be a good idea, if someone spends enough time to create custom symbols, to make them available for others to use.

User symbols can certainly be used if you're figuring out the data structure fields as you go, but as I mentioned repeatedly updating the user symbol source file, reassembling and loading into ReSource could be a bit of a pain. Though you might be able to use a ReSource macro to automatically reload the user symbols (I haven't tried that).
Quote:
Originally Posted by selco View Post
How would I do that? (Adding a BSS hunk)
Can I do that after starting disassembling with ReSource? I do not know in advance if/how many/how big strctures I will find in the code...?
Does that mean I add additional dummy variables to the code? How can I get rid of these variables later?
I don't think you can add a BSS hunk to an existing .rs file. You don't need to know exactly how many/how large any data structures used are, just make sure the dummy BSS hunk is large enough for all. If you're looking to create a fully re-assembleable source file, you could convert the ds.X lines in the BSS section to RS directives.

There are a couple of ways to create a BSS area. For example, suppose your original file is this:
Code:
	moveq	#0,d0
	rts

	dc.b	"Hello"
That assembles to this executable (hex dump):
Code:
00000000:  000003f3 00000000 00000001 00000000
00000010:  00000000 00000003 000003e9 00000003
00000020:  70004e75 48656c6c 6f000000 000003f2
The length of the code hunk is given in two places in the executable: in the table of hunk lengths at the start (offset $14), and after the HUNK_CODE ($000003E9) longword (offset $1C here). If you increase the first one, that creates a BSS area at the end of the code hunk. For example, add $1000 to the length to add a 16KB BSS area. So the hex dump becomes:
Code:
00000000:  000003f3 00000000 00000001 00000000
00000010:  00000000 00001003 000003e9 00000003
00000020:  70004e75 48656c6c 6f000000 000003f2
I prefer to create a separate BSS hunk, though doing that is slightly more involved. The executable with an extra separate $1000-longword BSS hunk would look like this:
Code:
00000000:  000003f3 00000000 00000002 00000000
00000010:  00000001 00000003 00001000 000003e9
00000020:  00000003 70004e75 48656c6c 6f000000
00000030:  000003f2 000003eb 00001000 000003f2
mark_k 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
SAS/C: Undefined symbols Yesideez Coders. C/C++ 14 13 February 2014 16:36
Settlers/copy protection Symbols macpegg support.Games 8 27 February 2009 05:23
ReSource 6.XX MrZammler request.Apps 7 30 October 2007 14:15
Hardware symbols includes like cia.i Photon Coders. General 6 10 March 2006 23:48
Resource Amigaboy request.Apps 2 16 August 2001 05:15

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 19:50.

Top

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