News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Assembly compiling back to rom format  (Read 3092 times)

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Assembly compiling back to rom format
« on: October 26, 2012, 06:15:17 pm »
Ok,I've decided to go the DTE route in my Turbo Graphx rom hacking project. So after a looooooooong search I've finally found a 6502 disassembler and assembler  that is compatible with my computer. TetraDAS Disassembler and HuCEngine Semi Duper IDE for anyone that's wondering. So naturally, my question is, how do I compile my rom back to PCE format? Is there a certain program or method you have have found that will do that for me? I've tried PCEAS2 but that program would even open up the Test.asm that came with it.

THanks in advance!

FAST6191

  • Hero Member
  • *****
  • Posts: 3019
    • View Profile
Re: Assembly compiling back to rom format
« Reply #1 on: October 26, 2012, 06:39:45 pm »
I will of course defer to others more versed in PCE/TG16 for this, but in general although you can theoretically disassemble and reassemble a binary just editing a few things along the way that is potentially somewhat tricky as the thing will be packed with code that is not assembly which has a nasty habit of troubling things (and that is before it tries to figure out what to do if you have added lines of code and not accounted for it somehow). Indeed for the few occasions it ever happens it is usually because someone spent ages getting the "source code" into a format the assembler cares to deal with. I will give you that theoretically/in an ideal world it should be as trivial as putting a filesystem back together, which is to say you double click and have it all rebuilt, but this is not really such a world.

Short version- if you just editing instructions consider editing them by hand (hand encoding ASM is not really that fun so nobody will really say anything if you do not head down this path), seeing if the debugging emulator has assembly options (many of the better debugging emulators and tools like IDA will, again though I am not versed in the PCE/TG16 so I can not point you at things for it), assembling with a standard assembler and stripping and headers and such from the newly assembled code (usually able to be done at batch file level in the end- it is a lot of what I do for the GBA and DS) and pasting over whatever needs changing (or pasting it to a location you have found and adding any jump (function)s or DMA/read to memory commands in the relevant places). Most of those are trivial compared to actually redoing things at the ASM level anyway.

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Re: Assembly compiling back to rom format
« Reply #2 on: October 26, 2012, 07:21:50 pm »
I've tried IDA and Madefen(spelling?) and they both aren't compatible with windows 7. Not even in cmd. >:(

Thank you FAST6191, I think I'll try that stripping pasting suggestion of yours. But for anyone else who knows how to convert ASM to (PCE)rom format, I would love to hear from you!
« Last Edit: October 26, 2012, 07:29:52 pm by Pikachumanson »

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7061
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Assembly compiling back to rom format
« Reply #3 on: October 29, 2012, 10:21:29 pm »
Yes, if you were expecting to automatically disassemble the entire ROM at once, it won't happen. The ROMs contain code and data. Disassemblers can only assume everything is code. Once it hits data, the disassembly is going to be incorrect as it tries to disassemble code that's not code, and may or may not line back up with the actual ASM code.

The only disassemblies that have been done are by hand, by people who took probably many hours manually separating the actual ASM code from the data. (and even those were from comparatively small early NES games. Early games that didn't have memory mappers to complicate things.
Though Disch did some work on Final Fantasy, he was still only able to decompile a few of the banks as I recall and not quite the entire game.)

I did a little work on a couple NES games, but it was tedious work copying blocks from FCEUX and then trying to figure out what the code does.
"My watch says 30 chickens" Google, 2018

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Re: Assembly compiling back to rom format
« Reply #4 on: October 30, 2012, 02:22:39 am »
Thanks! I'm learning something new everyday! I'm having a hard time with this project but i refuse to give up. Now if I could find a debugger for the Pce that will work correctly with windows 7. Damn I wish my C++ skills were up to par. I'm combing off that doc on implenting DTE for Y's 3 for the nes. Is it possible to use crystal tiles 2 as a debugger? I see it lets me view asm code but when I try to change a line of code it gives me an invalid command error. Also the asm commands look longer with five or six letter commands like addeq intead the usual three letter commands like add. Perhaps it is that way because it looks to geared towards nds roms. Anybody care to clear that up for me or point to an alternative program?  :banghead:

FAST6191

  • Hero Member
  • *****
  • Posts: 3019
    • View Profile
Re: Assembly compiling back to rom format
« Reply #5 on: October 30, 2012, 10:51:16 am »
Crystaltile2's assembly options are just ARM7 and ARM9 and not the odd HuC6280 thing the TG16 apparently used.

http://www.villehelin.com/wla.html might get you an assembler though (it may also provide a measure of disassembly). I have never really had that much trouble with windows 7 aside from drivers, but I still have XP machines and virtual machines I use for this sort of thing anyway; that IDA would not work for you points a deeper issue with the system for me though. By the looks of things a couple of the multi system emulators like http://tasvideos.org/Bizhawk/ReleaseHistory.html might be able to help out though and in a pinch you might also be able to do something with a related disassembler but that is not an idea path to take.

@KingMike didn't a couple of the pokemon crowd also do a complete disassembly for one of the GB games? Granted your point still stands.

BRPXQZME

  • Hero Member
  • *****
  • Posts: 4572
  • じー
    • View Profile
    • The BRPXQZME Network
Re: Assembly compiling back to rom format
« Reply #6 on: October 30, 2012, 03:47:59 pm »
Though Disch did some work on Final Fantasy, he was still only able to decompile a few of the banks as I recall and not quite the entire game.)
Yeah, there are a preposterous number of raw, unremarked bytes still floating around (you can tell from the lack of comments and there being a line for each byte D: ), and most of the assembly is still organized by bank. Still, it’s a start and he went to the trouble of making the thing assemblable. A competent assembly hacker shouldn’t have too much trouble picking up where he left off, should one wish to do so.
we are in a horrible and deadly danger