English Amiga Board


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

 
 
Thread Tools
Old 16 December 2019, 17:20   #1
Asman
68k

Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 717
Resourcer question(s)

I have question about Resourcer.

Background: main file is binary file loaded to address $6000.
So I have set origin to $6000 and code looks nice but there is for example
Code:
add.l #START+$2023,a1
and I want to change it to
Code:
add.l #$8023,a1
Is it possible to do that in Resourcer ?
Asman is offline  
Old 16 December 2019, 17:56   #2
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 51
Posts: 1,184
Perhaps not, if i remember right. You can of course clear Origin. Mostly I used CED for replacing START+$2 with $8. Or you can add in resourced file START=$6000. I sometimes set extra label too and manually resourced all offsets.
Don_Adan is offline  
Old 16 December 2019, 18:35   #3
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,309
As Don Adan said, I don't think it's possible. You can easily change it when assembling the source but not within ReSource, at least I didn't find any way to do that yet (but didn't care much either as it's not a big problem).

Last edited by StingRay; 16 December 2019 at 19:28. Reason: typo
StingRay is online now  
Old 16 December 2019, 18:42   #4
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,423
Hi Asman, do you want to do it automatically or manually?
Because you can manually use '*/ZAP/Zap2' (code mode).
ross is online now  
Old 16 December 2019, 19:25   #5
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,309
Zap/Zap2 won't work, it will still create the START+ label.
StingRay is online now  
Old 16 December 2019, 20:02   #6
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,423
Quote:
Originally Posted by StingRay View Post
Zap/Zap2 won't work, it will still create the START+ label.
Then I remembered badly.
However tonight I try, I seemed to have solved the problem .. but I probably just bypassed it somehow
ross is online now  
Old 16 December 2019, 20:31   #7
Asman
68k

Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 717
@Don_Adan, StingRay, ross.
Thanks for answers. Just few seconds ago I had crazy idea to make a symbol (LABELS/Create single/Symbol) and it works. I write down $8023 and now I see
Code:
 add.l #$8023,a1
I generated whole asm code to check if there is some symbol like $8023 = START+$2023, but there is not. I need to check if other combination works too, like
Code:
 add.l #CHARS+$80,a1
Thanks again.
Asman is offline  
Old 16 December 2019, 21:48   #8
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,423
Ok, I used this (I left a comment in the resourced code to remind me):
SYM/SYMBOLS/Custom Bases/- Base #x -/Use-> $value
But probably is the same as your LABELS/Create single/Symbol

I too often find myself trying the options since there are so many that remembering what they do is impossible
ross is online now  
Old 16 December 2019, 22:34   #9
Asman
68k

Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 717
I checked combination CHARS+$80 and it works too. It seems that Resource is so powerful than I thought. Poor me.
Asman is offline  
Old 17 December 2019, 00:47   #10
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,309
Quote:
Originally Posted by Asman View Post
Just few seconds ago I had crazy idea to make a symbol (LABELS/Create single/Symbol) and it works. I write down $8023 and now I see

This will of course work but you have to be careful when dealing with absolute address code as you have to decide manually if a label should be created or not as not everything with a START+ reference should be a label (which I actually thought is the case here otherwise I would have suggested using "labels/create single/symbol" too).


Anyway, ReSource is indeed powerful, didn't find anything which handles disassembling Amiga binaries better though IDA Pro is a good competitor.
StingRay is online now  
Old 17 December 2019, 07:57   #11
Bruce Abbott
Registered User

Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 297
Quote:
Originally Posted by StingRay View Post
ReSource is indeed powerful, didn't find anything which handles disassembling Amiga binaries better though IDA Pro is a good competitor.
At US$1879 it had better be good!
Bruce Abbott is offline  
Old 17 December 2019, 12:37   #12
Asman
68k

Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 717
Quote:
Originally Posted by StingRay View Post
This will of course work but you have to be careful when dealing with absolute address code as you have to decide manually if a label should be created or not as not everything with a START+ reference should be a label (which I actually thought is the case here otherwise I would have suggested using "labels/create single/symbol" too).


Anyway, ReSource is indeed powerful, didn't find anything which handles disassembling Amiga binaries better though IDA Pro is a good competitor.
Thanks a lot for advice, indeed I must be very careful and I thought that I just assemble resourced source and compare with original but it seems I need to improve my skills first. I was so wrong when I write that file is binary. In fact it is executable but the code inside it started from $6000. The loader loaded exe as binary. Then find the very first opcode $43f9 (which is first opcode in exe ) and then just copy code as data to location $6000.

Edit: Just for clarification loader is separate file.

Is it possible to generate executable but the code starts from fixed address, like $6000 ?
I use Asm-One and org $6000 but of course I trashed gfx memory. I know that there is LOAD directive but should I also use Abs memory when I run Asm-One and there are options about choosing space ?

Now I think that I will analyze exe header and perhaps is possible to generate some kind of mock file with fixed header and tail. Then inject data and then compare files.

Last edited by Asman; 17 December 2019 at 13:01. Reason: added clarification about loader file
Asman is offline  
Old 17 December 2019, 13:43   #13
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,423
Quote:
Originally Posted by Asman View Post
Is it possible to generate executable but the code starts from fixed address, like $6000 ?
If it's not inconvenient for you, you can use a utility in the WHDLoad package called 'Reloc'.
It take a normal hunk exe and create a binary relocated to an absolute memory position.
You can then create a little stub that copy this binary data to the defined position and launch it (with a different WinUAE session).
ross is online now  
Old 17 December 2019, 14:32   #14
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 2,423
Quote:
Originally Posted by ross View Post
SYM/SYMBOLS/Custom Bases/- Base #x -/Use-> $value
Now I even remember why I used Custom Bases instead of LABELS/Create single/Symbol (even if the effect is the same).
I had some recurring patterns and I was comfortable using the 'Use' function repeatedly.
I realized because I'm having a similar situation case
ross is online now  
Old 17 December 2019, 16:00   #15
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,566
Quote:
Originally Posted by Asman View Post
I was so wrong when I write that file is binary. In fact it is executable but the code inside it started from $6000. The loader loaded exe as binary.
Raw binaries were often written as hunk-format executables, because the assembler or linker in use couldn't output anything else. The important question is: does the executable have relocation hunks? If not, you may also ignore the hunk-format header.

Quote:
Is it possible to generate executable but the code starts from fixed address, like $6000 ?
Definitely not with hunk-format executables. They are always relocated and loaded to any free address by LoadSeg().

Quote:
Now I think that I will analyze exe header and perhaps is possible to generate some kind of mock file with fixed header and tail. Then inject data and then compare files.
Maybe you should only compare the binary part, when it is an absolute raw binary and the hunk-format structure is irrelevant.

You can easily convert a hunk-format executable into a raw binary with vlink:
vlink -brawbin1 -Tldscript -o binary hunkexe

With a linker script (called ldscript, see -T option) like this to relocate the program to $6000:
Code:
SECTIONS {
        . = 0x6000;
        out: { *(*) }
}
phx is offline  
Old 17 December 2019, 17:39   #16
Asman
68k

Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 717
@ross - thanks a lot. Indeed Reloc from WHDload did the job.

@phx - thanks a lot. The executable do not have any relocation hunks at all. There is only single HUNK_CODE. But I must admit that linker script is really magic for me, especially this *(*). For sure I need to learn how to write such script. Do you have any docs about it ?

Important for me is that now I can compare resourced source with binary data. As I checked I had about 40 bytes different in very first comparision. Binary data has 28112 bytes.
Asman is offline  
Old 17 December 2019, 23:07   #17
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,566
Quote:
Originally Posted by Asman View Post
There is only single HUNK_CODE.
Ok. So it was indeed an absolute binary file, embedded in hunk-format.

Quote:
But I must admit that linker script is really magic for me, especially this *(*).
Just noticed that Ross' suggestion with "Reloc" does exactly the same. That's probably easier, as long as you don't want to link more complex scenarios (for example output specific files or sections at other fixed addresses).

Short explanation: Before the ':' you have the name of the output section. It's "out" in this case. We don't care, as the result is a raw binary file, with one consecutive region. Within the {...} you define the input sections which are linked into the given output section.

The pattern in front of the parenthesis matches the file names to link, and the pattern within the parenthesis matches the section names. In our case we just want to merge all sections which are there, so "*(*)".

Quote:
For sure I need to learn how to write such script. Do you have any docs about it ?
https://ftp.gnu.org/old-gnu/Manuals/...pter/ld_3.html
That's for GNU-ld, but vlink should support most of it.
phx 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
Resourcer supporting OVERLAY hunk???? CFOU! Coders. General 1 07 March 2017 00:06
Amiga 1200...board revisions question / wire link modification question voyager_1701e support.Hardware 3 20 February 2014 13:32
Resourcer AC^Rbs Coders. General 4 02 October 2008 23:23
Sensible question mmmfreegoo support.Games 5 25 November 2006 18:10
A Question... DoaBlade request.Old Rare Games 2 06 January 2002 06:40

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 18:14.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.09191 seconds with 15 queries