• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Touched's MEGA-HUGE ASM Tutorial: How to ASM

Touched

Resident ASMAGICIAN
625
Posts
9
Years
    • Age 122
    • Seen Feb 1, 2018
    So I've been wanting to write one of these for a while. A first draft has been floating around for some time, and I know a number of people have read it, but I've finally got my act together and made it somewhat readable. I'm hosting the main document on GitHub so that people can point out errors there (and hopefully make contributions). This is still very much a work in progress, so suggestions are welcome.

    I've felt that many ASM Tutorials here miss the mark, because they have a focus on writing small snippets and very little actual explanation. ASM is surrounded in superstition and that seems to be changing, but there are a few topics that confuse a lot of people. Hopefully this document will clear that up somewhat. I try to do more explaining that a step by step tutorial. You can't learn ASM with a step by step process. It's too broad a topic for that to fit. You learn techniques and apply those techniques to a task. I want to equip you with the tools to learn for yourself.

    If there is any topic you feel I should cover, feel free to post here or on GitHub, but try to bear the aims of the document in mind. I don't want to do a tutorial, but I might do a case-study of some reverse engineering if you have ideas.

    Anyway, without further ado, here is the tutorial.
     
    Last edited:

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • So I've been wanting to write one of these for a while. A first draft has been floating around for some time, and I know a number of people have read it, but I've finally got my act together and made it somewhat readable. I'm hosting the main document on GitHub so that people can point out errors there (and hopefully make contributions). This is still very much a work in progress, so suggestions are welcome.

    I've felt that many ASM Tutorials here miss the mark, because they have a focus on writing small snippets and very little actual explanation. ASM is surrounded in superstition and that seems to be changing, but there are a few topics that confuse a lot of people. Hopefully this document will clear that up somewhat. I try to do more explaining that a step by step tutorial. You can't learn ASM with a step by step process. It's too broad a topic for that to fit. You learn techniques and apply those techniques to a task. I want to equip you with the tools to learn for yourself.

    If there is any topic you feel I should cover, feel free to post here or on GitHub, but try to bear the aims of the document in mind. I don't want to do a tutorial, but I might do a case-study of some reverse engineering if you have ideas.

    Anyway, without further ado, here is the tutorial.

    Good job. It's a nice and brief documentation of some important concepts. I particularly like how well done the SP section is, but this:
    The stack contains words (just like books - look how far my analogy extends!)
    I'm just baffled at how incredibly lame that was lol.
     
    1,682
    Posts
    8
    Years
    • Seen today
    This is exactly what I'm looking for: a documentation for ASM commands (I learn better this way).
    Let's see if I can make something useful or at least functional.
     

    Turtl3Skulll

    Blue Turtl3
    76
    Posts
    10
    Years
  • After reading practically every single ASM tutorial on PC, I believe (at least for myself) that ASM isn't hard, the issue with ASM Hacking is the fact that every tutorial tries to teach ONLY assembly instead of also focusing on how to find routines, and how to use a debugger correctly for finding things you'd want.

    So far the closest tutorial I've seen that accommodates to this, has been FBI's. If you were to implement in some part of the tutorial, the use of a debugger, such as VBA-SDL-H, and a way to locate tables, routines, etc. it would make this tutorial easier for beginners to know how to actually get into ASM Hacking, and would make this tutorial even better.
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    After reading practically every single ASM tutorial on PC, I believe (at least for myself) that ASM isn't hard, the issue with ASM Hacking is the fact that every tutorial tries to teach ONLY assembly instead of also focusing on how to find routines, and how to use a debugger correctly for finding things you'd want.

    So far the closest tutorial I've seen that accommodates to this, has been FBI's. If you were to implement in some part of the tutorial, the use of a debugger, such as VBA-SDL-H, and a way to locate tables, routines, etc. it would make this tutorial easier for beginners to know how to actually get into ASM Hacking, and would make this tutorial even better.

    I'm trying to think of a series of hacks that I could implement while writing up exactly what I did to implement them (debugging and all). The main problem with that is the ideas I have are often far too complicated to be suitable for newbies. If you have any ideas for something you'd like to see written in this fashion, please let me know. I kinda want to do one for each "level" of difficulty, starting at just above the level of HackMew's tutorial.

    The reason I go into theory quite a lot is because so many people get confused by that when learning. When you start to disassemble the game's code, seeing stuff like

    Code:
    sub sp, #0x10
    mov r0, sp
    mov r1, #0
    str r1, [r0]

    gets super confusing, because no one has ever seen the stack used that way. This kind of thing happens a lot when reading the game's code, so I thought I'd best clear that up in the beginning.
     

    Turtl3Skulll

    Blue Turtl3
    76
    Posts
    10
    Years
  • I'm trying to think of a series of hacks that I could implement while writing up exactly what I did to implement them (debugging and all). The main problem with that is the ideas I have are often far too complicated to be suitable for newbies. If you have any ideas for something you'd like to see written in this fashion, please let me know. I kinda want to do one for each "level" of difficulty, starting at just above the level of HackMew's tutorial.

    If you want some ideas, check out FBI's tutorial and that could spark some up, also you could redo things tools already do, so that new people understand what they are using, and feel like the code they are using is more relevant, such as: Shinyzer, teaching how to make shiny, changing the percentage of pokemon being shiny & re-implementing already known and popular hacks to give people the basics. Just like I remember you were recreating JPAN's engine to work with emerald, you could teach some of the routines used from there, and also teach how to port them over to different versions.

    The reason I go into theory quite a lot is because so many people get confused by that when learning...
    This kind of thing happens a lot when reading the game's code, so I thought I'd best clear that up in the beginning.
    By all means continue to go into theory, you can't learn to code ASM w/o knowing its commands, I just wanted to make sure you could also include real life implementations, which you say you will. Good luck finding newbie routines to teach though XD
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • If you want some ideas, check out FBI's tutorial and that could spark some up, also you could redo things tools already do, so that new people understand what they are using, and feel like the code they are using is more relevant, such as: Shinyzer, teaching how to make shiny, changing the percentage of pokemon being shiny & re-implementing already known and popular hacks to give people the basics. Just like I remember you were recreating JPAN's engine to work with emerald, you could teach some of the routines used from there, and also teach how to port them over to different versions.


    By all means continue to go into theory, you can't learn to code ASM w/o knowing its commands, I just wanted to make sure you could also include real life implementations, which you say you will. Good luck finding newbie routines to teach though XD

    Finding things is mostly practice and guess-work. Though, as you get better, the guesses you make are closer to accurate. I suggest you try things. Try to make that cool routine you've been thinking of, trying and figuring out stuff yourself is also part of the learning curve. I don't think I've said this before, but when I started this stuff I was trying to find where surf was being validated. 7 days and about 23 "I give ups" later, I finally found it. Sure, it took some guidance from my seniors, but honestly, it's a lot of time which I also put in. If you have trouble, ask in the ASM help thread. That place is completely abandoned because I guess people see making requests in the ASM resource thread as 90x easier than trying it out themselves. It's my only regret about making the ASM resource thread, while I share findings, I've made it easy to be ignorant and use ASM. The moral is try stuff out if you're interested in learning, while seeking tips from us. Also the second moral is, share research, not code :P
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    Finding things is mostly practice and guess-work. Though, as you get better, the guesses you make are closer to accurate. I suggest you try things. Try to make that cool routine you've been thinking of, trying and figuring out stuff yourself is also part of the learning curve. I don't think I've said this before, but when I started this stuff I was trying to find where surf was being validated. 7 days and about 23 "I give ups" later, I finally found it. Sure, it took some guidance from my seniors, but honestly, it's a lot of time which I also put in. If you have trouble, ask in the ASM help thread. That place is completely abandoned because I guess people see making requests in the ASM resource thread as 90x easier than trying it out themselves. It's my only regret about making the ASM resource thread, while I share findings, I've made it easy to be ignorant and use ASM. The moral is try stuff out if you're interested in learning, while seeking tips from us. Also the second moral is, share research, not code :P

    Yeah, while it is mostly intuition that allows you to find things, there are a number of techniques that aren't immediately obvious to newbies. Also, I'm 90% sure many of them just skip over the word IDA if you use it in a sentence.
     

    Turtl3Skulll

    Blue Turtl3
    76
    Posts
    10
    Years
  • Finding things is mostly practice and guess-work. Though, as you get better, the guesses you make are closer to accurate. I suggest you try things. Try to make that cool routine you've been thinking of, trying and figuring out stuff yourself is also part of the learning curve. The moral is try stuff out if you're interested in learning, while seeking tips from us. Also the second moral is, share research, not code :P

    Oh I completely understand what you mean, practice does help if you know how to do something, but a lot of the people that decide to start ASM don't understand the debugger at all. I didn't know how to use the debugger correctly until I read your tutorial, I didn't know how to even begin to look for a routine since people would just say:
    "set a breakpoint" w/o telling you "set a break point before the battle if you want to find a routine that has to do with the battle animation/trainers/rival pokemon stats/etc."

    As counterproductive as it sounds, we have to dumb down the techniques of ASM hacking to get more people to begin it, once a big enough crowd starts ASM it'll bring about better hacks, tools, tutorials, and everything.
    Mainly I just wish in ASM tutorials they would explain the process of finding a routine (such as what FBI did in his) and implementing a hack of it, just to have a newbie feel like they accomplished something, instead of feeling like they just read a wall of text, and only know what a stack pointer is, without knowledge of what can be done with it.

    Also, I'm 90% sure many of them just skip over the word IDA if you use it in a sentence.
    Exactly! instead of just using it in a sentence, make a tutorial on what it is, how it works, where some known things are, etc. The IDA is a great resource, but it has never been regarded glorious enough to make a tutorial on it.

    Anyways, I do love both your guys' work so don't think I'm criticizing, I just want everyone who looks at these tutorials to learn something and be able to apply it to their ideas, without having to keep reading a sentence over and over to understand what its saying (like I did when I read HackMew's 2yrs ago)
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Oh I completely understand what you mean, practice does help if you know how to do something, but a lot of the people that decide to start ASM don't understand the debugger at all. I didn't know how to use the debugger correctly until I read your tutorial, I didn't know how to even begin to look for a routine since people would just say:
    "set a breakpoint" w/o telling you "set a break point before the battle if you want to find a routine that has to do with the battle animation/trainers/rival pokemon stats/etc."

    As counterproductive as it sounds, we have to dumb down the techniques of ASM hacking to get more people to begin it, once a big enough crowd starts ASM it'll bring about better hacks, tools, tutorials, and everything.
    Mainly I just wish in ASM tutorials they would explain the process of finding a routine (such as what FBI did in his) and implementing a hack of it, just to have a newbie feel like they accomplished something, instead of feeling like they just read a wall of text, and only know what a stack pointer is, without knowledge of what can be done with it.


    Exactly! instead of just using it in a sentence, make a tutorial on what it is, how it works, where some known things are, etc. The IDA is a great resource, but it has never been regarded glorious enough to make a tutorial on it.

    Anyways, I do love both your guys' work so don't think I'm criticizing, I just want everyone who looks at these tutorials to learn something and be able to apply it to their ideas, without having to keep reading a sentence over and over to understand what its saying (like I did when I read HackMew's 2yrs ago)

    That's fair, a tutorial on IDA has been long overdue. The issue is, IDA costs big money, and hobby hackers can't afford it. It is available illegally for those who really want it, but the issue with creating a tutorial about IDA, is that utilizing IDA for basic ASM hacks is kind of simple. It's just the same thing as opening your ROM in a disassembler, except some of the stuff are labeled by knizz and contributors to his DB. Of course, I down play it a lot, there is a ton of features IDA comes along with, such as synced emulation, running python scripts, editing/adding documentation (but those aren't really required for ASM hacks, they just make things a little easier I suppose). It's mainly good for X-refs. pseudo code viewer, and the labeled names.

    It's kind of hard to make a tutorial IDA focused because, there's really not much you need to know to get started. There are a lot of IDA tutorials out there already for those who actually want to check it out in depth. I personally use IDA as a point of reference and do my searching in the debugger for harder projects. Sometimes, things in IDA aren't labeled/are mislabeled/hard to find, so you'd need to settle back to the old fashioned way of finding things. I feel like the bigger issue when it comes to finding routines, is that people are unaware of how things like the LR works, how to execute breakpoints on dynamic data. Just yesterday, I was helping someone find the location of a check to give an item, I gave him a function to set the breakpoint on, but after the game broke he didn't know what to do. It didn't occur to him to look at the Link Register to tell where the parent function was (a solid example of not knowing the basics of how commands are working).

    I guess someone could make a tutorial on all of these topics combined, but time is pretty scarce (at least for me, and Touched). The both of us feel as though no one is reading the tutorials we're writing, so we're wasting time. Asking questions is also rather important. Almost no one asks questions, everyone is an expert, lol. Maybe in the near future you'll see something from one of us~

    We do have a low population on ASM hackers, but I blame the ASM request thread. Imagine it being something like Map request thread or Script request thread or something similar, it just sounds so stupid. Bleh, I feel like going back and deleting all my posts there, it's a great resource, but now it's just stunting hacker growth I feel. This community has maybe 3 competent ASM hackers, 4 still learning, and that's about it. It's pathetically low, really, but people don't even understand pointers and scripting even, let alone basic ASM concepts. Just getting PMs about "How do I compile X?" or "How does X pointer work?" or "What is a table of X?" further proves the point. I try to help out and answer questions as best as I can, but our ASM help thread is unfrequented, and people prefer PM/VMing me (which gets realllyyyyy annoying I'll have you know).
    Oh I'm ranting again, well, oops :D
     

    Turtl3Skulll

    Blue Turtl3
    76
    Posts
    10
    Years
  • That's fair, a tutorial on IDA has been long overdue. The issue is, IDA costs big money, and hobby hackers can't afford it. It is available illegally for those who really want it, but the issue with creating a tutorial about IDA, is that utilizing IDA for basic ASM hacks is kind of simple. It's just the same thing as opening your ROM in a disassembler, except some of the stuff are labeled by knizz and contributors to his DB. Of course, I down play it a lot, there is a ton of features IDA comes along with, such as synced emulation, running python scripts, editing/adding documentation (but those aren't really required for ASM hacks, they just make things a little easier I suppose). It's mainly good for X-refs. pseudo code viewer, and the labeled names.

    It's kind of hard to make a tutorial IDA focused because, there's really not much you need to know to get started. There are a lot of IDA tutorials out there already for those who actually want to check it out in depth. I personally use IDA as a point of reference and do my searching in the debugger for harder projects. Sometimes, things in IDA aren't labeled/are mislabeled/hard to find, so you'd need to settle back to the old fashioned way of finding things. I feel like the bigger issue when it comes to finding routines, is that people are unaware of how things like the LR works, how to execute breakpoints on dynamic data. Just yesterday, I was helping someone find the location of a check to give an item, I gave him a function to set the breakpoint on, but after the game broke he didn't know what to do. It didn't occur to him to look at the Link Register to tell where the parent function was (a solid example of not knowing the basics of how commands are working).

    I guess someone could make a tutorial on all of these topics combined, but time is pretty scarce (at least for me, and Touched). The both of us feel as though no one is reading the tutorials we're writing, so we're wasting time. Asking questions is also rather important. Almost no one asks questions, everyone is an expert, lol. Maybe in the near future you'll see something from one of us~

    We do have a low population on ASM hackers, but I blame the ASM request thread. Imagine it being something like Map request thread or Script request thread or something similar, it just sounds so stupid. Bleh, I feel like going back and deleting all my posts there, it's a great resource, but now it's just stunting hacker growth I feel. This community has maybe 3 competent ASM hackers, 4 still learning, and that's about it. It's pathetically low, really, but people don't even understand pointers and scripting even, let alone basic ASM concepts. Just getting PMs about "How do I compile X?" or "How does X pointer work?" or "What is a table of X?" further proves the point. I try to help out and answer questions as best as I can, but our ASM help thread is unfrequented, and people prefer PM/VMing me (which gets realllyyyyy annoying I'll have you know).
    Oh I'm ranting again, well, oops :D

    Then I'll try to get a solid grasp (enough to not just do, but also teach) on ASM from both your tutorials & if I get time I'll attempt to write up a tutorial on these things you guys don't feel are given enough attention, but don't think everyone takes what you two do for granted, I'm always looking forward to seeing your posts, I don't try as hard as I should to take all the info in, but I always appreciate seeing how much you guys know and share with the community.
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Then I'll try to get a solid grasp (enough to not just do, but also teach) on ASM from both your tutorials & if I get time I'll attempt to write up a tutorial on these things you guys don't feel are given enough attention, but don't think everyone takes what you two do for granted, I'm always looking forward to seeing your posts, I don't try as hard as I should to take all the info in, but I always appreciate seeing how much you guys know and share with the community.

    Also the iirc we frequent has a pretty good conversion rate. Most people who join trying to learn ASM, will learn when they join the IIRC. Just that 1 to 1 advice is pretty helpful ;O

    http://chat.linkandzelda.com:9090/?channels=rh
     
    Back
    Top