As i am new to this process, i am trying to just disassemble a file and then reassemble it, and i come up to some issues.
I know that there are experienced people here in this forum so maybe they could help in this process which is trivial to them.
What i want to do is to disassemble a bin file, and then reassemble , without changes and test that everything works.
So i am using :
yazd shinobi.prg shinobiyazd.asm
i get the asm file starting with:
ORG 0000h
; --- START PROC L0000 ---
L0000: NOP etc etc
trying to reassemble with pasmo:
pasmo shinobiyazd.asm shinobi.prg
yields these errors:
ERROR on line 3664 of file shinobiyazd.asm
ERROR: End line expected but '*'found
editing the asm file, indeed there is an extra asterisk at the end of the NOP:
L1892: NOP*
the same happens at line 3824.
Why yazd inserted these asterisks?
After removing them the assembly succeeds, but the produced binary differs from the original binary in several bytes when i do
a data comparison in HxD ! I had not changed any data in the asm file. Shouldn't be identical?
Which this explain why the assembled file when put inside the disk, it does not work and causes resets.
Does anyone know what am i doing wrong in this process?
thanks in advance!
you should give yazd the load- and startadress of shinobi as it trys to follow the flow of the code.
what i have seen with ghidra: shinobi is also a little bit tricky as it self-modifies some adresses of calls and jumps
the startaddress is the xD00 as it shows in cpcdiskxp ?
what is the load and how do i pass to yazd ?
I never used Yazd, but if you have trouble with it, you can use Disark instead (see my signature), a clever (I hope) disassembler which can rebuilt sources for many assembler (rasm, winape, pasmo, sdcc...). It generates labels and if you know where data zones are, you declare them (as a symbol table) and it will generate DB/DW automatically.
thanks Targhan, i will give it a try.
cool stuff! i just disassembled and reassembled with your tool disark and with rasm (by roudoudou) and the generated file
is identical. Nice.
Targhan,
I coud not find it, perhaps i missed it, but is there any option for disark to display the disassembled file along with the RAM addresses, the decoded text and the various numbers inside the file in HEX format?
You can add the address via the --adrInComments command.
> the decoded text and the various numbers inside the file in HEX format?
No sure what that means exactly... You mean a list of DBs for data areas?
But by using the --src8bitsValuesInHex and --src16bitsValuesInHex, the generated numbers will be in hex. See http://julien-nevo.com/disark/index.php/usage/
thank you, i generated the file with all details.
The only thing i did not understand is how to find out the loadAddress.
I peeked the asm file that Fessor generated and found out that it is the 0xC80. The only thing that bothers me is how to find out this value.
>I peeked the asm file that Fessor generated and found out that it is the 0xC80. The only thing that bothers me is how to find out this value.
I guess you extracted the binary from memory? If your binary was extracted from 0xc80, then that's your loadAddress. I guess it's simply where the code begins.
For the Load-Address i simply looked at the AMSDOS-Header in Winapes Inspect-Disc-Function.Then i extracted the File from the Disk Image without Amdos-Header so i dont have to take its size into account when loading the file to the disassembler
In Ghidra i followed the code into the initialization where Shinobi LDIRs some Datablocks to upper Memory-Adresses, created the Memoryblocks and copied the Datablocks manually to this Memoryblocks to look which labels would have been created.Its browsing through the Listing and guessing, which registers may be references to addresses. And after a short time i found the cross-references to the numbering in the filenames.
Targhan, I extracted it from the file, as i do not know how to do this while it is loaded in memory.
Fessor, thanks for the mini guide, it seems that i have to study and get used to its context and how things work.