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

Author Topic: Asm hacking  (Read 12214 times)

tomaitheous

  • Hero Member
  • *****
  • Posts: 543
    • View Profile
    • PC Engine Dev
Asm hacking
« on: February 05, 2014, 04:43:40 pm »
Curious, how do you guys handle your ASM hacking projects?

 Do you use a hex editor to do all your asm hacking, or do you use an assembler? If you use an assembler, do you assembly directly into the rom or do copy the assembled code into the rom?

KC

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Asm hacking
« Reply #1 on: February 05, 2014, 04:55:54 pm »
The worst thing you can do is hard code changes into the binary. So I'm using an assembler that creates modified copies of the executables and overlays. It's very important to me that every rebuild starts with a clean state.

tryphon

  • Hero Member
  • *****
  • Posts: 722
    • View Profile
Re: Asm hacking
« Reply #2 on: February 05, 2014, 05:30:00 pm »
For my Genesis hacking, I use Easy68K to write my hacked routines, then I wrote a python script to insert it to a clean ROM.

For PS2 and PSP, I use a very basic assembler (PS2DIS), and a Python script I wrote that copy the binary data in free space (it handles the free space), insert a jmp in the right place of the code, and add a jmp at the end of my custom code to where it should go back to the original code. Here again, I start from a clean ROM.

Scio

  • Full Member
  • ***
  • Posts: 155
    • View Profile
Re: Asm hacking
« Reply #3 on: February 05, 2014, 05:47:40 pm »
I have a clean ROM where I insert the assembled code into, then I just copy the HEX to the ROM of the game I'm working on (taking care to leave a JMP at the end of it).

I used to copy directly into the ROM, but I always forgot to account for space, so it's better that way.

Drakon

  • Sr. Member
  • ****
  • Posts: 277
    • View Profile
    • 16 Bit Gamer
Re: Asm hacking
« Reply #4 on: February 05, 2014, 06:17:20 pm »
Curious, how do you guys handle your ASM hacking projects?

 Do you use a hex editor to do all your asm hacking, or do you use an assembler? If you use an assembler, do you assembly directly into the rom or do copy the assembled code into the rom?

Just a hex editor and notepad to type out my hex before copying and pasting it in.  The more I manually plunk in the more I memorize the codes and the faster I can work that way.

FAST6191

  • Hero Member
  • *****
  • Posts: 2469
    • View Profile
Re: Asm hacking
« Reply #5 on: February 05, 2014, 06:59:58 pm »
Most of my assembly projects are reverse engineering.

If I can apply it in cheat form I will do that.

Otherwise I will have text form and write and inject either with the assembler or by hand. I tend not to do massive rewrites of functions.

Either way a hex editor is not the tool I would be looking at for anything beyond injection of a few instructions. Text editor with some basic syntax, possibly nice IDE level text editor should I be making use of things like being able to name my memory locations, and then have the assembler insert or insert by hand if I need to do something special.

snarfblam

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 589
  • CANT HACK METROID
    • View Profile
    • snarfblam
Re: Asm hacking
« Reply #6 on: February 05, 2014, 09:59:25 pm »
I've never been a fan of hex editing ASM. Much like KC, for me a build process is important. I actually wrote my own 6502 assembler because, well, because I'm picky and wanted certain features. My assembler actually generates symbol files for FCEUX so things are easier to understand in the debugger.

This type of process lets you easily organize and modify code without having to keep track of every little byte you've changed and makes debugging over 9000 times easier.

STARWIN

  • Sr. Member
  • ****
  • Posts: 445
    • View Profile
Re: Asm hacking
« Reply #7 on: February 06, 2014, 11:40:01 am »
Just a hex editor and notepad to type out my hex before copying and pasting it in.  The more I manually plunk in the more I memorize the codes and the faster I can work that way.
This is how I do it as well, though I'm not so interested in memorizing things than I'm interested both in understanding the low level well enough and simply in avoiding tools that I would have to learn to use (or code?). I have only done small hacks though.

FAST6191

  • Hero Member
  • *****
  • Posts: 2469
    • View Profile
Re: Asm hacking
« Reply #8 on: February 06, 2014, 12:05:05 pm »
Would it then be wrong to say the general consensus is you should be able to hand encode/decode an instruction but realistically actually doing it should be left as a party trick.

KC

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Asm hacking
« Reply #9 on: February 06, 2014, 12:42:05 pm »
Would it then be wrong to say the general consensus is you should be able to hand encode/decode an instruction but realistically actually doing it should be left as a party trick.
That may realistically work on primitive CISC cpus, but I want to see someone do that on a complex ARM instruction.

tryphon

  • Hero Member
  • *****
  • Posts: 722
    • View Profile
Re: Asm hacking
« Reply #10 on: February 06, 2014, 12:56:53 pm »
Even on a 68000, which is not exactly a RISC, I want to see...

Why on earth would you want to manually assemble/dissassemble something ?

Among other things, it'd show you didn't understand that if something doesn't require thinking (and so is assembling), then a computer will do it much better than you. So you're probably a bad programmer.

justin3009

  • Hero Member
  • *****
  • Posts: 1603
  • Welp
    • View Profile
Re: Asm hacking
« Reply #11 on: February 06, 2014, 01:28:28 pm »
I only do SNES right now, but I tend to have Geiger's open to make any physical changes, but if it's changes I make that are REALLY bad, I have the same ROM open in Translhextion BEFORE the changes.  So if it ends up bad, resave with Transl then reload with Geiger's.

Of course, I make back-ups as well before any MAJOR overhauls.  But minor ones I just do the method above.
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

FAST6191

  • Hero Member
  • *****
  • Posts: 2469
    • View Profile
Re: Asm hacking
« Reply #12 on: February 06, 2014, 01:43:32 pm »
I was thinking more if you have something like http://nocash.emubase.de/gbatek.htm#armconditionfield (scroll up a tiny bit) or http://nocash.emubase.de/fullsnes.htm#cpumemoryandregistertransfers in front of you then you should be able to hand encode or decode an instruction, anything after that though is you just showing off.

Zoinkity

  • Hero Member
  • *****
  • Posts: 557
    • View Profile
Re: Asm hacking
« Reply #13 on: February 06, 2014, 02:43:16 pm »
I'm almost always shoving new code into a spot made by rewriting existing code, and since R4300i assemblers aren't exactly numerous to begin with I find writing everything by hand a lot easier.  Plus, to avoid changing sometimes thousands of hardcoded hardware addresses, it's nice to just hand code something that might burn a few cycles but with enough redundancy to ensure it compresses within the same block size.

N64 hacking is a bit of a party trick anyway, but even for larger swaths of code it's just a lot easier to know it's going to fit, not fry half a dozen registers, or complain about some stupid voodoo magic or external reference it blasted well doesn't need to know about. 

So, at least in my case, it's hex editor the whole way.

infidelity

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Asm hacking
« Reply #14 on: February 06, 2014, 03:42:09 pm »
I hack completely via a hex editor. I like to be able to view everything with the Code Data Logger within FCEUX.

Everyone has they're own method of writing 6502. I happened to learn mostly from kuja killer, and that was how he wrote/modified 6502 asm.

I can look at hex values and know just about all of the opcodes for them from memory.

I've gotten so much flack from people saying I don't know how to do asm if I do it via a hex editor. It doesn't matter how you write it or what method you use, as long as it works.

I'm sure if I learned from someone else, and they actualy 'wrote' it out, then probably today that would be the way I write asm.

KC

  • Full Member
  • ***
  • Posts: 209
    • View Profile
Re: Asm hacking
« Reply #15 on: February 06, 2014, 04:28:19 pm »
... and since R4300i assemblers aren't exactly numerous to begin with I find writing everything by hand a lot easier. ...

N64 hacking is a bit of a party trick anyway, but even for larger swaths of code it's just a lot easier to know it's going to fit, not fry half a dozen registers, or complain about some stupid voodoo magic or external reference it blasted well doesn't need to know about. 

It's a bit off topic, but if you really do spend a lot of time on this, armips might be something you could make use of. It currently lacks anything N64 specific, but it's open source and if you are interested, you could contribute those parts. Most of the instruction set is already there, too. It comes with lots of other features too, one of which is checking that code doesn't get bigger than a size you specified.
Having a decent assembler for N64 would definitely be neat.

FAST6191

  • Hero Member
  • *****
  • Posts: 2469
    • View Profile
Re: Asm hacking
« Reply #16 on: February 06, 2014, 05:26:28 pm »
I've gotten so much flack from people saying I don't know how to do asm if I do it via a hex editor. It doesn't matter how you write it or what method you use, as long as it works.

Did you mean "people can not follow me" or "because I hand encode/decode people say it does not count". For the latter then people are wrong, for the former then fine but I am not sure it is a good thing.

As for "as long as it works"... devs doing that is I believe why we end up with threads like http://www.romhacking.net/forum/index.php/topic,14700 , one of the reasons project failure rates are so high and generally why ROM hacking is not easy as it might be.

Drakon

  • Sr. Member
  • ****
  • Posts: 277
    • View Profile
    • 16 Bit Gamer
Re: Asm hacking
« Reply #17 on: February 06, 2014, 06:12:33 pm »
This is how I do it as well, though I'm not so interested in memorizing things than I'm interested both in understanding the low level well enough and simply in avoiding tools that I would have to learn to use (or code?). I have only done small hacks though.

There's actually not that many opcodes to learn for some 8-bit systems.  The better I'm understanding the asm the faster I'm getting at writing my own code.

I hack completely via a hex editor. I like to be able to view everything with the Code Data Logger within FCEUX.

Everyone has they're own method of writing 6502. I happened to learn mostly from kuja killer, and that was how he wrote/modified 6502 asm.

I can look at hex values and know just about all of the opcodes for them from memory.

I've gotten so much flack from people saying I don't know how to do asm if I do it via a hex editor. It doesn't matter how you write it or what method you use, as long as it works.

I'm sure if I learned from someone else, and they actualy 'wrote' it out, then probably today that would be the way I write asm.

That's exactly how I work too so don't feel so bad about the flack you get.

snarfblam

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 589
  • CANT HACK METROID
    • View Profile
    • snarfblam
Re: Asm hacking
« Reply #18 on: February 06, 2014, 06:21:09 pm »
I've gotten so much flack from people saying I don't know how to do asm if I do it via a hex editor. It doesn't matter how you write it or what method you use, as long as it works.

Hey, nice to see you on RHDN!

I doubt most people question your ability to write ASM. The only time I've seen anyone give you flak is on NesDev, when you posted code in raw hex. For those of us who don't code in raw hex, it's meaningless numbers (and on a homebrew forum, everyone uses an assembler).

You're a better hacker than I. It's just that I honestly don't understand how you keep track of so many things with your extensive hacks using only a hex editor (and notes, I presume). I couldn't do it. I'm kinda scatterbrained, so I need lots of management and organization with my projects.

Pokeytax

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Cavespeak
Re: Asm hacking
« Reply #19 on: February 06, 2014, 07:07:57 pm »
When doing Dreamcast hacking, I have been doing SH-4 coding by hand with a reference for lack of an alternative - that's fun. Lots of copy and paste of existing code.
Doing GBA/NDS hacking, I generally just use NO$GBA's change instruction to alter the code and obtain the hex.
Doing PSX hacking I definitely used an assembler (actually the cross-compiler MassHexASM although armips is perfectly adequate).
For actual insertion a hex editor.

I guess it varies by the situation.

Curious if there's any difference between professional coders and pure hobbyists. Personally I don't have a computer science background, avoid command lines when possible, and do things like compression and script extraction & insertion in Excel VBA because that's what I use every day at work. All my routines use Excel as an IDE with formulas to handle branch offsets, etc. If coding were my job that kind of sloppiness and inefficiency would probably horrify me, but it's the path of least resistance. I'm sorry to the people who made nice tools I am too clueless to use  :(