Lance Koijer 2.0
Lance Koijer
- 105
- Posts
- 7
- Years
- Criscanto Town
- Seen Jan 31, 2024
Hello guys..
I am trying to code an ASM that checks if the current HP is lower or equal to the Half of the 1st Party Pokémon's Total HP.
I have thought how to get the half in an ASM but the problem I have encountered is the byte indicator is not writing in the loaded address..
here's the code:
it feels to me that it's either the storing of the byte or the branch checking makes the code not functioning. If someone can help me fix this, it is much appreciated. Thanks.
I am trying to code an ASM that checks if the current HP is lower or equal to the Half of the 1st Party Pokémon's Total HP.
I have thought how to get the half in an ASM but the problem I have encountered is the byte indicator is not writing in the loaded address..
here's the code:
Code:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r3, lr}
ldr r0, =(0x20242Dc) @loads the Total HP
ldrb r0, [r0]
ldr r1, =(0x20242Da) @loads the current hp
ldrb r1, [r1]
mov r2, #0x5 @multiplies to 5 to get the half
mul r0, r2, r0 @gets the half of Total HP
mov r3, #0xA @moves one decimal to current HP
mul r1, r3, r1 @gets the value of Current HP
cmp r1, r0 @compares if Current HP is higher than Half of the total HP
bhi push2
ldr r1, =(0x203c1b4) @freespace
mov r0, #0x1
strb r1, [r0] @stores byte 1 to indicate that the Current HP is lower than or equal the half of total HP
pop {r0-r3, pc}
push2:
ldr r1, =(0x203c1b4)
mov r0, #0x0
strb r1, [r0] @stores byte 0 to indicate that the Current HP is higher than the half of total HP
pop {r0-r3, pc}
it feels to me that it's either the storing of the byte or the branch checking makes the code not functioning. If someone can help me fix this, it is much appreciated. Thanks.