• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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.

[ASM & Hex] Trainer ID with ASM

  • 18
    Posts
    11
    Years
    • Seen May 14, 2023
    I've been following HackMews guide to ASM and I've got it to work.
    (https://www.pokecommunity.com/threads/117917#ASM1)

    But now I'm trying to make an ASM routine to show me the trainer id, so I've used the RAM map to find the trainer ID is in the location '[0x0300500C] + 0x000A' and that its not a half word like the secret ID is.

    So I updated the ASM routine to have 'ldr r0, [r0, #0xA]' instead of 'ldrh r0, [r0, #0xC]' because its no longer a halfword, and I also updated the line after to use 'str' instead of 'strh' for the same reason.

    It tells me the value 0x0000000A is too big... although this is smaller than 0xC, so I'm a bit stuck.
     
    Last edited:
    I've been following HackMews guide to ASM and I've got it to work.
    (https://www.pokecommunity.com/threads/117917#ASM1)

    But now I'm trying to make an ASM routine to show me the trainer id, so I've used the RAM map to find the trainer ID is in the location '[0x0300500C] + 0x000A' and that its not a half word like the secret ID is.

    So I updated the ASM routine to have 'ldr r0, [r0, #0xA]' instead of 'ldrh r0, [r0, #0xC]' because its no longer a halfword, and I also updated the line after to use 'str' instead of 'strh' for the same reason.

    It tells me the value 0x0000000A is too big... although this is smaller than 0xC, so I'm a bit stuck.

    I'm pretty sure the Trainer ID is a halfword. But regardless, you are getting that error because 0xA is a multiple of 2 bytes instead of 4, so you cannot load a word from an offset that isn't word-aligned.
     
    So how would I go about loading this, is there any way of aligning it or accessing this data differently?
     
    Last edited:
    I'm pretty sure the Trainer ID is a halfword. But regardless, you are getting that error because 0xA is a multiple of 2 bytes instead of 4, so you cannot load a word from an offset that isn't word-aligned.
    do you mean to use thumb. to align two bits per command? do I understand correctly?
     
    To load the trainer ID, you would do the following:

    Code:
    .align 2
    .thumb
    
    ldr r0, =(0x0300500c)
    ldr r0, [r0]
    ldrh r0, [r0, #0xa]

    The difference is "ldrh" vs. "ldr." The former loads a halfword (2 bytes) and can do so in multiplies of two bytes, whereas the latter loads a full word (4 bytes) and can only do so from word-aligned offsets (eg. 4, 8, C, etc).

    The .align 2 at the top causes the compiled code to be word aligned as well, if I remember correctly. But this is not inherently related to loading values from the DMA
     
    Last edited:
    Back
    Top