• 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✓] SOLVED:need help with looping my get-iv routine

232
Posts
13
Years
    • Seen Sep 10, 2019
    I'm trying to make a routine that gets the IV values of a pokemon whose slot is stored at var 0x8007 and store those values into vars 0x8001-0x8006 and the total of those values into var 0x8000. I'm having a difficult time in allowing the routine to loop. here's my routine:
    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global decryptor
    
    main:
        push {r0-r5, lr}
        ldr r0, var_8007        @slot number should be in var_8007
        ldrh r0, [r0]
        mov r1, #0x64
        mul r1, r1, r0
        ldr r0, partypoke
        add r5, r1, r0        @slot loaded
        mov r1, #0x27
        ldr r3, var_8001
        mov r4, #0x0
    
    decrypt:
        mov r0, r5
        ldr r2, poke_decrypt
        bl linker
        strh r0, [r3]            @store result into var_8001-8006
        add r4, r4, r0
        add r1, r1, #0x1
        cmp r1, #0x2D
        beq exit
        add r3, r3, #0x2
        b decrypt
    
    exit:
        ldr r1, var_8000        @load var_8000
        strh r4, [r1]
        pop {r0-r5, pc}
    
    linker:
        bx r2
    
    .align 2
    var_8000:    .word 0x20370B8
    var_8001:    .word 0x20370BA
    var_8007:    .word 0x20370C6
    partypoke:    .word 0x2024284
    poke_decrypt:    .word 0x803FBE8 + 1
    When it attempts to loop, the game freezes.
     
    Last edited:
    325
    Posts
    10
    Years
  • I'm trying to make a routine that gets the IV values of a pokemon whose slot is stored at var 0x8007 and store those values into vars 0x8001-0x8006 and the total of those values into var 0x8000. I'm having a difficult time in allowing the routine to loop. here's my routine:
    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global decryptor
    
    main:
        push {r0-r5, lr}
        ldr r0, var_8007        @slot number should be in var_8007
        ldrh r0, [r0]
        mov r1, #0x64
        mul r1, r1, r0
        ldr r0, partypoke
        add r5, r1, r0        @slot loaded
        mov r1, #0x27
        ldr r3, var_8001
        mov r4, #0x0
    
    decrypt:
        mov r0, r5
        ldr r2, poke_decrypt
        bl linker
        strh r0, [r3]            @store result into var_8001-8006
        add r4, r4, r0
        add r1, r1, #0x1
        cmp r1, #0x2D
        beq exit
        add r3, r3, #0x2
        b decrypt
    
    exit:
        ldr r1, var_8000        @load var_8000
        strh r4, [r1]
        pop {r0-r5, pc}
    
    linker:
        bx r2
    
    .align 2
    var_8000:    .word 0x20370B8
    var_8001:    .word 0x20370BA
    var_8007:    .word 0x20370C6
    partypoke:    .word 0x2024284
    poke_decrypt:    .word 0x803FBE8 + 1
    When it attempts to loop, the game freezes.

    r1 is changed during the pokedecrypt routine, use a higher register to store stuff, like you did for r5. Also the same thing is happening with r3.
     
    232
    Posts
    13
    Years
    • Seen Sep 10, 2019
    r1 is changed during the pokedecrypt routine, use a higher register to store stuff, like you did for r5. Also the same thing is happening with r3.

    Thank you very much. Your other post also helps a lot too!

    Here's the fixed routine:
    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global getiv
    
    main:
        push {r4-r7, lr}
        ldr r0, =(0x20370C6)        @slot number should be in var_8007
        ldrh r0, [r0]
        mov r1, #0x64
        mul r1, r1, r0
        ldr r0, =(0x2024284) @partyram
        add r5, r1, r0        @slot loaded
        mov r6, #0x27
        mov r1, r6
        ldr r7, =(0x20370BA) @var8001
        mov r4, #0x0
    
    decrypt:
        mov r0, r5
        ldr r2, =(0x803FBE8|1) @getattr
        bl linker
        strh r0, [r7]            @store result into var_8001
        add r4, r4, r0
        add r6, r6, #0x1
        cmp r6, #0x2D
        beq exit
        mov r1, r6
        add r7, r7, #0x2
        b decrypt
    
    exit:
        ldr r1, =(0x20370B8)        @load var_8000
        strh r4, [r1]
        pop {r4-r7, pc}
    
    linker:
        bx r2
    
    .align 2
     
    Last edited:
    Back
    Top