HEX2ASM

Discussion in 'Utilities' started by Selbi, Dec 12, 2010.

Thread Status:
Not open for further replies.
  1. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,398
    Location:
    Northern Germany
    Something I hate about Hex editors is, that I can't do a lot of things I could do in normal text editors. If I'm pissed so much of using them, I always dig out IDA to convert the Hex into an ASM array (with dc.X commands). This, however, is annoying as well, so I decided to make a tiny program for it.


    Running the original menutext.bin file through it (level select text) looks like this:


    [​IMG]


    And the output looks like this:



    dc.b $17,$22,$15,$15,$1E,$FF,$18,$19,$1C,$1C,$FF,$10,$1F,$1E,$15,$FF,$FF,$23,$24,$11,$17,$15,$FF,$01
    dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$02


    dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$03


    dc.b $1C,$11,$12,$0F,$22,$19,$1E,$24,$18,$FF,$10,$1F,$1E,$15,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$01


    dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$02


    dc.b $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$23,$24,$11,$17,$15,$FF,$03


    ...



    Download: http://selbi.hapisan.com/HEX2ASM.exe


    Special Thanks to MarkeyJester for a 5 minutes beta testing!
     
    Nat The Porcupine likes this.
  2. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,791
    This sir, is one of the several most useful tools I've found to use, you wouldn't believe the number of times I've had to manually copy code from a hex editor and reorganise in the assembler's format.
     
  3. Dark Lips

    Dark Lips Well-Known Member Member

    Joined:
    Nov 14, 2008
    Messages:
    290
    Location:
    Wolverhampton UK
    Great work, this is so useful :lol:
     
  4. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,228
    Location:
    UK
    Thats darn cool selbi, may give it a wirl.
     
  5. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,398
    Location:
    Northern Germany
    Update, v1.1:

    • Data is now directly being written to the output path (using a StreamWriter), rather than storing everything to a variable and then saving it. This allows you to convert huge files in the matter seconds!
    • Added a progress bar.
    • Reading from offsets and setting length (e.g Offset=$0001E000; Length=$2000 bytes).
    • Adding comments at the end of each line, showing you the offset of the first value in that line (Sorry Mercury, labels as well would be... unnecessary).


    But I totally have no interests in working on this program anymore. The source is already fucked up so much... it was hard enough to do the things listed above (I even think that there are still bugs releated to words and longwords when reading from offsets and the progress bar only really works when you convert the entire file).


    Download: http://selbi.hapisan.com/HEX2ASM-v1.1.exe


    That said, here's the source (I'm pretty sure the experienced people in those modern languages will do an epic failpalm now :v:): http://selbi.hapisan.com/HEX2ASM-Source.rar


    If anyone has the patience to crawl through this messy code to clean it up, fix the remaining bugs or add more handy features, just go ahead!
     
  6. SamplingMastersNix

    SamplingMastersNix 64-bit Sonic Hacking Novice Member

    Joined:
    Feb 13, 2010
    Messages:
    54
    Location:
    Madison, MS
    Any chance of converting Hex to ASM with not just the define constraint but with the move, add, branch, and all the other commands as well, or does that not work with data?


    Also, I want to convert ASM into HEX, so I can replace the .bin data. Can you reverse the process, Selbi?
     
    Last edited by a moderator: Dec 23, 2010
  7. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,398
    Location:
    Northern Germany
    Yes, use IDA Pro.

    It'd be easier to just use ASM68K (or SNASM68K if you're using it). Make a new file called build2bin.bat or whatever you it to be and put this into it:



    Code:
    asm68k FILEYOUWANTTOBEINBINFORMAT.asm, ASM2BIN.bin
     
Thread Status:
Not open for further replies.