• 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.

[ASM & Hex] Trainer ID with ASM

18
Posts
10
Years
    • Seen May 14, 2023
    I've been following HackMews guide to ASM and I've got it to work.
    (https://www.pokecommunity.com/showthread.php?t=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:
    88
    Posts
    7
    Years
    • Seen Jan 16, 2020
    I've been following HackMews guide to ASM and I've got it to work.
    (https://www.pokecommunity.com/showthread.php?t=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.
     
    18
    Posts
    10
    Years
    • Seen May 14, 2023
    So how would I go about loading this, is there any way of aligning it or accessing this data differently?
     
    Last edited:

    Dinisk

    DinisK
    89
    Posts
    7
    Years
    • Seen Apr 27, 2019
    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?
     
    88
    Posts
    7
    Years
    • Seen Jan 16, 2020
    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