16 April 2016, 22:16 | #1 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
ReSource - How to re-load ASM file?
Hello, I am experimenting with ReSource. I have opened a binary using the "P > Open binary file" option. I then saved the ASM using the "SV > Save .asm" option. However I have no idea how to re-load the ASM file once edited.
Also is there a way how to edit a line directly from ReSource? Or add additional lines? |
16 April 2016, 22:40 | #2 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,333
|
You can't load an assembly language source file into ReSource. (Well, not without assembling it and loading the resulting executable...)
If you're wanting to save a work-in-progress disassembly, use the "Save .RS" menu item. Then load that .rs file into ReSource and continue your work later. |
16 April 2016, 23:03 | #3 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Quote:
For example if I have a line "MOVE.L D1,(A0)" and I want to change it to "MOVE.B (A1)+,D1". How can that be done? |
|
16 April 2016, 23:08 | #4 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,333
|
If you mean basically binary-patching the file (or at least, the in-memory version that ReSource is working on), look in the * (SPECIAL FUNCTIONS) menu. ZAP->Zap2 could/should do what you want.
|
16 April 2016, 23:17 | #5 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Quote:
Many thanks for your help. |
|
19 April 2016, 20:53 | #6 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
How do I add a new command with ReSource?
I went through the manual. I read that to add an empty line I had to LABELS > Create Single > Full-Line Comment and enter ";" as comment. I then tried to go to Special Functions > Zap > Zap2. However this shows me the next line command. If I try Zap instead of Zap2 I get a blank box but whatever I enter gets refused. Last edited by Sim085; 19 April 2016 at 21:49. |
19 April 2016, 21:57 | #7 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,333
|
You can enter a full-line comment with an assembly language opcode. Begin it with a ; to tell ReSource to not put a semicolon on that line in its dissassembly.
For example if you enter this as a full-line comment: ; MOVEQ #0,D0 then in the disassembly (and .asm output) there will be MOVEQ #0,D0 which will of course, if you run an assembler on the .asm file, produce an executable with that extra instruction in. However comments like that are still comments as far as ReSource is concerned, i.e. just text. The disassembler doesn't "understand" it as an instruction. The Zap/Zap2 commands are used to patch (overwrite) bytes of code with different bytes/instructions of your choice. You can't make extra space and put new instructions in there, other than by the full-line comment method. |
19 April 2016, 22:25 | #8 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
So I am doing as you say, i.e. - when I add the full line comment I enter the following:
"\tMOVEA.L\tD0,D2" I then use the option SV > Save Executable. I then load the executable again (P > Open Load File). However the command I added as a comment is not there. So I guess the only option is to save as .asm and then use an assembler to re-assemble and only after that disassemble with Resource. Off to search for an assembler... |
19 April 2016, 22:47 | #9 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,333
|
I'm not sure exactly what you're trying to do, but is it definitely not possible to patch/change existing instructions, instead of adding new ones? Sometimes, especially if the program you're disassembling was written in C, you can free up a few bytes of space by modifying/adjusting a few instructions to be shorter.
For example, if there is MOVEA.L (4).L,A6 you could patch that to MOVEA.L (4).W,A6 to save two bytes. Or MOVE.L #0,D0 --> MOVEQ #0,D0 to save four bytes. Getting a disassembly to the state where reassembling the .asm file produces a working executable can be quite a long process. For example, if there are any jump tables which you didn't disassemble correctly, your reassembled executable will most likely break/crash. |
20 April 2016, 18:22 | #10 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
So after reading this yesterday I decided that the best approach to go through the program little by little and understand what each line is doing.
That said I have found some commands which I do not understand what they mean; Example (not in that order): Code:
Output.MSG db 'Out',0,0 lbL001666 dl $1F0E201C dw $B20 Does anyone know what these are? |
20 April 2016, 18:29 | #11 |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
|
Db is data byte. Dw is data word and dl is data long
In devpac it would be dc.b, dc.w and dc.l In asm one it would be blk.b, blk.w and blk.l |
20 April 2016, 19:01 | #12 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
How come these instructions are different from one editor to another? and how come these instructions are not in the 68000 manuals?
(btw ... asm one accepted dc.b) Last edited by Sim085; 20 April 2016 at 20:27. |
20 April 2016, 20:29 | #13 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,333
|
db/dc.b etc. are not 68000 instructions. They are assembler directives, which tell the assembler to include that data in the executable.
For whatever reason different assemblers have a different directive to do that. In ReSource you can switch between db/dw/dl and dc.b/dc.w/dc.l by clicking the Options 1 button, then changing Assembler from Macro68 to Assem. For example, suppose you have a program which prints a text string. You need to include your string in the program somehow. Code:
lea (String,PC),A0 bsr print_text ... more code here ... String: dc.b "Hello world!",0 |
20 April 2016, 20:47 | #14 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
dc.b, dc.w, dc.l blk.b, blk.w, blk.l db, dw, dl byte, word, long ADis, D68k and IRA disassemblers all use dc.<size> so the default ReSource output is less common. |
|
20 April 2016, 21:28 | #15 |
Moderator
Join Date: Nov 2001
Location: Germany
Posts: 866
|
|
24 April 2016, 18:46 | #16 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
I hit some more problems
I am not sure if this is related to what mark_k was saying. In the .asm file generated from ReSource I have some code as follows: Code:
BRA.B START+$097C ; line 1 ORI.B #????$31,D0 ; line 2 ORI.B #????$6F,???? ; line 3 ???? ; line 4 So with regards to 'line 1' I converted 097C from HEX to DEC (2428). I looked for this line in the .asm file and I can see this is a normal code. So why isn't ReSource creating a label like it does in other places? I am asking this to see if I am working this one right. Can I replace this with a label? As for the question marks. ReSource manual says "ReSource displays question marks when the data type is code and there is no legal instruction at that location". So what can I do for line 2, 3 and 4? |
24 April 2016, 21:16 | #17 |
Registered User
Join Date: Aug 2004
Location:
Posts: 3,333
|
Okay, first of all there's little point in bothering to output a .asm file until you have the disassembly in a much more complete state, since you won't be able to re-assemble it without the assembler giving loads of errors. (Unless you're just using the .asm file to load into a text editor and navigate it, I guess.)
The offset in the example you gave (START+$097C) is in bytes relative to the start of the program. It has nothing to do with line numbers in the .asm text file. In ReSource, move to the BRA.B START+$097C instruction and press the right arrow key. That will move to offset $97C in the disassembly. Do there seem to be valid instructions there? If so then the BRA.B instruction may well actually be an instruction, as opposed to data being disassembled as code. Press the left arrow key to return to the BRA.B instruction, then press F6 to automatically generate a label at offet $097C. The "instructions" after the BRA.B in your example are not code, but some kind of data. Move to the first ORI.B and press lAmiga-A to convert to ASCII string. Does that make sense? If not try lAmiga-W to convert to words. It may be that the BRA.B isn't actually code either. Do the instructions before the BRA.B look normal/valid, i.e. without ??? in? Rather than manually generating labels for every START+ reference, you can use the Project->Disassemble menu item and have ReSource do it for you. Sometimes it doesn't work for the whole executable for some reason, so you may need to select that menu item more than once. ReSource's automatic disassembly isn't perfect and it may create labels where it's not appropriate. In that case you can move to the line with the bogus label and press - to remove it. |
26 April 2016, 01:31 | #18 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
So I would say the following code is valid...
Code:
00056C TST.B (A1)+ 00056E BNE.B START+$056C I did use the Disassemble option but parts like this one were left without labels. Quote:
Now this one is more tricky for me as not really know if the results are what is to be expected. Given ... Code:
ORI.B #????$6F,D0 ORI.B #????$6F,???? dw 4 ... Code:
dw 0 dw $2264 dw 8 dw $2064 dw 4 ; the line at the end ... |
|
26 April 2016, 08:56 | #19 | ||
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Quote:
It doesn't matter if dl, dw or db is used. It affects how compact and readable the data is but not the assembler output. |
||
26 April 2016, 21:59 | #20 | ||
Registered User
Join Date: Aug 2004
Location:
Posts: 3,333
|
Quote:
Quote:
In the case of the specific data you gave, it may be that the initial dw 0 is padding to longword-align the following data. By the way, I highly recommend you download the ReSource PDF user manual, and follow the tutorial in it. |
||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
asm code file errors and external file locations | Brick Nash | support.WinUAE | 0 | 06 April 2015 17:14 |
Problem to load config file and quicksavestate | Kloks | support.WinUAE | 23 | 30 March 2013 18:35 |
Cancelling load config file requester resets emulation | mark_k | support.WinUAE | 2 | 18 February 2012 09:34 |
Help! Trying to Load .DMS file..... | Triumph | support.WinUAE | 4 | 17 February 2009 20:37 |
|
|