• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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.

Help Thread: ASM & Disassembly

Status
Not open for further replies.
Hello, I've got another problem and I still don't understand basic things. Help would be appreciated.
So, I tried to insert [S-HIGHLIGHT]this routine[/S-HIGHLIGHT]. Now, the routine consists of two parts. I inserted the first one, the item check routine, to offset 0x78D310. However I had some trouble with the other one. Here's the code
Spoiler:


The first thing is I tried many item editors, but there's no such thing as "effect number". There's mystery bytes, index, special, but no effect number. So, my question is what do I write here?

Another thing is that the author of the routine wrote I thought I knew what I should do however I was wrong.
The problem is my offset was 0x78D310. And that would mean that there's one digit missing. So, my second question is how do I write the offset here. Do I write it "0x8myoffset" or "0xmyoffset"? Oh and also do I reverse the order or is reversing only necessary to pointers?

There's something else. Let's assume I inserted both routines. Where is this item? Does the place depend on the "effect number"? Also, what's the index of this new item? How would I give it to player if I don't know the index? Besides, do I have to write a script to make this item work or is it unnecessary?
Ah, sorry. I'm using LSA's item editor atm, so I'm used to that. In other editors, you'll probably want to edit the first special byte. Should be the same for KDS's routine as well; he said mystery byte, but I think he meant the first special byte, since that's if I'm not mistaken, the 18th byte in the item data structure that we all love. You'll want to use an unused number of course; don't give Heat Rock the special byte 22 in hex for example, or you'll end up with a second Soul Dew. For your second question, its .routine: .word 0x08myoffset. Don't reverse the order btw.
Also, I think you're a bit confused. It's not really "Where is this item?", because you're making a new one :p. What you want to do is open up your item editor, find an unused item index (the ????? slots) and make your new item. Name it Heat Rock, give it your desired special byte, etc. Also, you don't need to write a script for this item, because my ASMAGIX will automatically make it work. Enjoy your 8 turns of Sunny Day :D.

EDIT: Also, XX XX XX is just the reversed pointer to the location of your heat rock routine. For example, if you inserted it at 0x800000, you'd put 01 00 80.
 
I've got a big problem. I found [S-HIGHLIGHT]that routine[/S-HIGHLIGHT]. It's supposed to change the EVs of trainers' pokemon. However there are many things I don't understand about it...I'm looking for someone who could explain it to me in detail. My rom is fire red.
So, the first part is actually simple and it's about inserting a routine. But something's strange...The author says:
The bulk of this code is at xF90000- that part doesn't have to go there, it can be moved to wherever you have free space. Just make sure you change Method_Addr to whatever you change the offset to + 1.
Basically all of the code is at F90000 and I insert it at the exact place in my rom. However there are also two bytes (that aren't 00 in the compiled routine) and I don't know what to do with them. Should I copy them and paste into my rom(at the same offset) or just ignore them?
Moving on
You will also need to find x1000 bytes of space, and change the .EV_Table variable in the method to point to it (I used xF00000). This is where the spreads will go. The method gives you 256 spreads to use- this is not full control, but it is more than you are likely to need (the Emerald Battle Frontier only uses around 36 IIRC). The EV Spread table format is:...
To make things less complicated I didn't change the .EV_Table and decided to also use 0xF00000.
I don't understand, however, how I'm supposed to "point to it". Is it done by pointers? If so where do I insert those? At what offset?
Then...
To assign an EV spread to a trainer's pokemon, set the value that was formerly their IVs to which slot in the table you want that pokemon to use. If you are using A-Trainer, this value is erroneously marked as AI Value. Note that the method only works for trainers with custom movesets and items- if they use default movesets or items, it will only affect IVs. It will still work if you manually give the trainer the moves it would have by default or explicitly define their mons as being empty-handed though.
Alright, I checked it in A-trainer and there is a value called "AI value". But I have no idea how to set it to a slot in the table. I tried looking for pokemon's offsets but there are only trainers' ones.
Could anyone help me, please?
 
I've got a big problem. I found [S-HIGHLIGHT]that routine[/S-HIGHLIGHT]. It's supposed to change the EVs of trainers' pokemon. However there are many things I don't understand about it...I'm looking for someone who could explain it to me in detail. My rom is fire red.
So, the first part is actually simple and it's about inserting a routine. But something's strange...The author says:
Basically all of the code is at F90000 and I insert it at the exact place in my rom. However there are also two bytes (that aren't 00 in the compiled routine) and I don't know what to do with them. Should I copy them and paste into my rom(at the same offset) or just ignore them?
Moving on To make things less complicated I didn't change the .EV_Table and decided to also use 0xF00000.
I don't understand, however, how I'm supposed to "point to it". Is it done by pointers? If so where do I insert those? At what offset?
Then...Alright, I checked it in A-trainer and there is a value called "AI value". But I have no idea how to set it to a slot in the table. I tried looking for pokemon's offsets but there are only trainers' ones.
Could anyone help me, please?

Okay, this is just from a vague memory of looking at that thread so bear with me:
1. Do you mean there are 00 00s originally at F90000? Or do you mean that they're part of the ASM bin. file? If the first, leave them alone and paste it a few bytes below or go to a new offset. The quote says you can literally post the code anywhere. If the second, just paste it along with the rest of the code.

2. Okay so make your table. Let's say you put it at 0x900000. In the ASM code itself, near the bottom, there should be a place that says: .EV_Table variable: . After that, put a space and write .word 0x08 and then the offset to your table, in this case .word 0x08900000.

3. In your EV spread table (which can have 255 entries), make your spread. How to do so should be listed in the thread. Now, say it is the first entry in your list. Go into A-Trainer or whatever trainer editor you use and go to the Pokemon that will use that particular EV spread. Go to the "AI Value" or corresponding value and type in 01 or just 1. If the EV spread was the second entry, type in 02 or 2. And so on and so forth.
(In A-Trainer, Go to "Pokemon Data" and its the "AI Value", In Jambo's Unnamed Trainer Editor, its the "IVs" section next to the Pokemon's Level)

Hope this helped a bit.
 
Last edited:
I found this routine somewhere, and I've tried to find it again , but I cannot find it anywhere! Who made this routine? and how can I figure out how to use it!

Spoiler:
 
Last edited:
I found this routine somewhere, and I've tried to find it again , but I cannot find it anywhere! Who made this routine? and how can I figure out how to use it!

Spoiler:

That's FBI agent's ability switcher. Its explanation is in his post.
 
Thank you! I looked everywhere for that. I didn't want to use it willy-nilly without knowing who made it/who to give credit to.
 
Thank you! I looked everywhere for that. I didn't want to use it willy-nilly without knowing who made it/who to give credit to.

You can probably tell if it's me depending on the word "linker" and how I assign variables using their direct address. Most people name "linker" something else and they use a .VAR or something for variables :D



Well, yesterday i tried to do something and realised i do not understand a few things, such as bit shifting and swi. Can anyone clarify those?

Bit shifting is just binary manipulation and swi are software interrupts. SWI commands can be read up on at gbatek, there's quite a few and the technical details are very important.

I reccomend you read ShinyQuagsire's tutorial if you're just starting off and want to learn about bit shifting. Once you've got a handle on that, you can come back and read the rest of this post.

Bit shifting is just a binary manipulation and works just as it does on paper. There are two types of possible shifts, a left shift and a right shift. The left shift takes the current value in binary form and appends a zero to it, it then removes the leading bit. The right shift takes the current value in binary form and prefix's a 0 to it and removes the trailing bit.

Keeping in mind registers can only hold 32 bits (4-bytes)
Code:
mov r0, #0x1
lsl r0, r0, #0x1

After the mov instruction r0 would contain "00000001" in hex (which in this case is also the binary representation). Doing that lsl r0, r0, #0x1 command, as I explained, would then yield "00000010" in binary or "00000002" in hex.

Lets try something a little more complicated.

Code:
mov r0, #0x10
lsr r0, r0, #0x2

Here r0 after the mov instruction would contain '00000010" in hex, or "00010000" in binary. Now if we apply the lsr on the binary form we remove two trailing bits and prefix two zeros. That would give us: "00000100" or 0x4 in hex.

You'll notice that I'm showing you 8 bit values for the binary representation of a register which is supposed to contain 32 bits (4 bytes). That's because I'm way too lazy to type all of those zeros, and it doesn't matter for the small values we used :D
 
This is an extremely stupid question but... Well, I'm used xse scripts like this- (extremely basic script)
Spoiler:


Simple xse script, but what is this.. an ASM script? -
Spoiler:


That was just a random script I found on this thread... Anyway, what would you exactly call this type of script, and what program would you insert it in? XSE, or something else...

Again, sorry for the stupidest question on here but I just started learning scripting.... haha.
 
This is an extremely stupid question but... Well, I'm used xse scripts like this- (extremely basic script)
Spoiler:


Simple xse script, but what is this.. an ASM script? -
Spoiler:


That was just a random script I found on this thread... Anyway, what would you exactly call this type of script, and what program would you insert it in? XSE, or something else...

Again, sorry for the stupidest question on here but I just started learning scripting.... haha.

That's an assembly program. It's different from scripts and it definitely doesn't use XSE to compile. I suggest first learning some more complicated scripts and experience the ROM hacking world a little more before coming back to this topic.

I could explain it to you now, but I feel like it would confuse you even more. If you're interested there are tutorials about ASM in the tutorials section of this forum.
 
That's an assembly program. It's different from scripts and it definitely doesn't use XSE to compile. I suggest first learning some more complicated scripts and experience the ROM hacking world a little more before coming back to this topic.

I could explain it to you now, but I feel like it would confuse you even more. If you're interested there are tutorials about ASM in the tutorials section of this forum.

I have actually read and now know the concept of asm and what the basic things do, registers and such. I just don't know exacty what you use to compile these assembly scripts, and how they work. If possible, I'd love it if you could explain (in a basic way) what to use to compile assembly scripts and very briefly what an example script does :) To much to ask? Hehe... I feel I could understand you explaining asm to me if I re-read the explanation for a while, I feel if would really help a lot.

-Thanks
 
I have actually read and now know the concept of asm and what the basic things do, registers and such. I just don't know exacty what you use to compile these assembly scripts, and how they work. If possible, I'd love it if you could explain (in a basic way) what to use to compile assembly scripts and very briefly what an example script does :) To much to ask? Hehe... I feel I could understand you explaining asm to me if I re-read the explanation for a while, I feel if would really help a lot.

-Thanks

https://www.pokecommunity.com/threads/313906

Btw, in ASM, it's a routine, not a script.
 
So, I'm here to ask many questions lol.

WHAT ARE REGISTERS FOR AND HOW THEY WILL ACT WHEN THE ROUTINE RUNS
★I'm a bit uncertain on how registers work when the routine has been called and I still dont know what register I will push in order for me to create a routine. I also dont know how will I use them when they are pushed. To make it short, what are registers for?★

HOW ASM'ers HERE KNOW WHAT RAM OFFSET WILL BE USED AND HOW THEY CAN LOCATE THE HEXES THAT NEED TO BE REPLACED
★Most of FBI routines have RAM OFFSET(correct me if I am wrong: like 0x02aaaaaaa: something like that) at the end. How they know what that ram offset does and importance in the routine they created. And After they made the routine, they will replace some bytes in Hex Editor in order to call that, and one thing I observed is they often used 00 00 48 blah blah then the reversed offset of the routine which is unknown to me what these bytes before the reversed +1 pointer of the routine do to execute the routine.★
WHAT WILL I START AS A BEGINNER?
★Since I am Beginner, I know that I need to master all the codes given by JPANs and HACKMEWs tutorial, but what would be the routine's function I start to create, do I need to study first how to change the status of a pokemon when routine has been called?★
that's all.
 
So, I'm here to ask many questions lol.

WHAT ARE REGISTERS FOR AND HOW THEY WILL ACT WHEN THE ROUTINE RUNS
★I'm a bit uncertain on how registers work when the routine has been called and I still dont know what register I will push in order for me to create a routine. I also dont know how will I use them when they are pushed. To make it short, what are registers for?★

HOW ASM'ers HERE KNOW WHAT RAM OFFSET WILL BE USED AND HOW THEY CAN LOCATE THE HEXES THAT NEED TO BE REPLACED
★Most of FBI routines have RAM OFFSET(correct me if I am wrong: like 0x02aaaaaaa: something like that) at the end. How they know what that ram offset does and importance in the routine they created. And After they made the routine, they will replace some bytes in Hex Editor in order to call that, and one thing I observed is they often used 00 00 48 blah blah then the reversed offset of the routine which is unknown to me what these bytes before the reversed +1 pointer of the routine do to execute the routine.★
WHAT WILL I START AS A BEGINNER?
★Since I am Beginner, I know that I need to master all the codes given by JPANs and HACKMEWs tutorial, but what would be the routine's function I start to create, do I need to study first how to change the status of a pokemon when routine has been called?★
that's all.

1) I sense knowledge gaps in your questions. Did you actually read any ASM tutorials thoroughly? Try reading Jpan's thumb tutorial, he explains what each register is, in terms of functionality. Registers are just like 4 byte memory storage, which you can apply transformations to via ASM instructions such as sub, add, mul, mov ect. Some registers are special though, in the sense that you can't use all of these operations on them and they are expected to hold certain values. The program counter is an example of this. Normally you shouldn't use a register without pushing/popping it, save for the first 4 registers (r0-r3) in SAFE function calls. I say safe, because calling your own function from another existing function without proper preparation may mess up the yield of the function you're branching from.

2) When searching for things there's a kinda weird process which I use. First I check Knizz's IDA to see if he's discovered it already. If he hasn't, or if the address is DMA I would try to find where in the ROM the change occurs. Sometimes you get lucky and the DMA address has an easy algorithm to find the DMA address. Normally this isn't the case, and sometimes the game uses malloc. Then I backtrack and follow until I find where the change is done in RAM. Somethings are harder to find than others, but normally it's a similar process.

The Byte replacements you're talking about is normally just a hex version of instructions like this:
Code:
ldr rX, =(0xInsertion address +1)
bx rX
It's basically just like a jump in scripting. Though you'll notice, like jump, it doesn't store a return address, so we need to make our routine return manually by having a bx ect ourselves.

3) For Hackmew's tutorial, I would only read the first one. The second one doesn't really teach anything, and is too big of a technical jump for a beginner (not to mention his algorithm for shinies isn't very good). For starting off, I'd read Jpan's tutorial for a technical reference, then HackMew's first or ShinyQuagsire's tutorial are both similar. From there, you're rather screwed, because no one has a tutorial which would act as a good second step :D
 
1) I sense knowledge gaps in your questions. Did you actually read any ASM tutorials thoroughly? Try reading Jpan's thumb tutorial, he explains what each register is, in terms of functionality. Registers are just like 4 byte memory storage, which you can apply transformations to via ASM instructions such as sub, add, mul, mov ect. Some registers are special though, in the sense that you can't use all of these operations on them and they are expected to hold certain values. The program counter is an example of this. Normally you shouldn't use a register without pushing/popping it, save for the first 4 registers (r0-r3) in SAFE function calls. I say safe, because calling your own function from another existing function without proper preparation may mess up the yield of the function you're branching from.

2) When searching for things there's a kinda weird process which I use. First I check Knizz's IDA to see if he's discovered it already. If he hasn't, or if the address is DMA I would try to find where in the ROM the change occurs. Sometimes you get lucky and the DMA address has an easy algorithm to find the DMA address. Normally this isn't the case, and sometimes the game uses malloc. Then I backtrack and follow until I find where the change is done in RAM. Somethings are harder to find than others, but normally it's a similar process.

The Byte replacements you're talking about is normally just a hex version of instructions like this:
Code:
ldr rX, =(0xInsertion address +1)
bx rX
It's basically just like a jump in scripting. Though you'll notice, like jump, it doesn't store a return address, so we need to make our routine return manually by having a bx ect ourselves.

3) For Hackmew's tutorial, I would only read the first one. The second one doesn't really teach anything, and is too big of a technical jump for a beginner (not to mention his algorithm for shinies isn't very good). For starting off, I'd read Jpan's tutorial for a technical reference, then HackMew's first or ShinyQuagsire's tutorial are both similar. From there, you're rather screwed, because no one has a tutorial which would act as a good second step :D

Ahhm so all routines push 4 registers only? that always bother my mind, I dont know what to push and what will I use, anyways, I downloaded knizz's IDA but I dont know how to use it... Thanks anyway
 
Ahhm so all routines push 4 registers only? that always bother my mind, I dont know what to push and what will I use, anyways, I downloaded knizz's IDA but I dont know how to use it... Thanks anyway

No, the first 4 are defined as Parameters in functions, thus don't need to be pushed for function calls. You should generally be pushing every register you want to preserve though. Knowing the technicalities will allow you to save some operation time and space by omitting excessive operations such as pushing needlessly.

To use Knizz's IDA, you need a program called IDA pro. Version 6.5 is the one I'm using. The program isn't free legally, and there are some websites with cracked versions which you should definitely avoid.
 
No, the first 4 are defined as Parameters in functions, thus don't need to be pushed for function calls. You should generally be pushing every register you want to preserve though. Knowing the technicalities will allow you to save some operation time and space by omitting excessive operations such as pushing needlessly.

To use Knizz's IDA, you need a program called IDA pro. Version 6.5 is the one I'm using. The program isn't free legally, and there are some websites with cracked versions which you should definitely avoid.

Ahhh Thanks pal, I still really cant understand the concept of registers, if it is ok to you, I want to be your student, I'll read again the JPANs tutorial
 
I read some tutorials on ASM, but there are many things that I don't understand. So, I decided to do something with ASM, something very simple but to no avail. I wanted to do a routine that adds 2 numbers and then create a script using XSE and insert it to somebody.
Here's my ASM:
Spoiler:


I also don't know why, but sometimes this code couldn't compile. I had to change some lines(for example adding r2 register). Oh and is pushing and popping necessary here? FBI mentioned earlier that registers r0-r4 don't have to be pushed.

I inserted this routine at 0x8378D0.
And here's my XSE code:
Spoiler:


Unfortunately it doesn't work. When I talk with a person who I assigned the script to I get "Does it work? 1".
Could someone help, please?
 
I read some tutorials on ASM, but there are many things that I don't understand. So, I decided to do something with ASM, something very simple but to no avail. I wanted to do a routine that adds 2 numbers and then create a script using XSE and insert it to somebody.
Here's my ASM:
Spoiler:


I also don't know why, but sometimes this code couldn't compile. I had to change some lines(for example adding r2 register). Oh and is pushing and popping necessary here? FBI mentioned earlier that registers r0-r4 don't have to be pushed.

I inserted this routine at 0x8378D0.
And here's my XSE code:
Spoiler:


Unfortunately it doesn't work. When I talk with a person who I assigned the script to I get "Does it work? 1".
Could someone help, please?
Your ASM routine isn't dumping the final number into the LASTRESULT variable. Basically, you're coming up with a number, but not really putting it anywhere. I'm not experienced enough to tell you how to fix it though. Sorry!
 
Status
Not open for further replies.
Back
Top