- 2
- Posts
- 7
- Years
- Seen Apr 13, 2018
I'm trying to learn ASM to help my brother in his hack, I tried to do a simple routine that would act like a "copy half-word into variable 0x800D at (pointer + 0x800D)"
The objective of this is to help him on scripting.
After reading some tutorials and trying to understand working routines I simply don't get why this didn't work, I'm sorry if this look idiot, but is better than don't asking.
.align 2
.thumb
main:
push {r0-r1,lr}
ldr r0, .pointer
ldr r1, .var
add r0, r0, r1
ldrh r0, [r0]
strh r0, [r1]
pop {r0-r1,pc}
.align 2
.pointer:
.word 0x020270B6 + (0x8004 * 2)
.var:
.word 0x020270B6 + (0x800D * 2)
You would store the pointer in variables 0x8004 and 0x8005, and then set variable 0x800D to a valor that would be added to the pointer in 0x8004 and 0x8005, after this, the routine would take the half-word in pointer2 (0x8004 0x8005 + 0x800D) and store it in 0x800D.
But the game simply crash, I'm putting +1 in the callasm.
The objective of this is to help him on scripting.
After reading some tutorials and trying to understand working routines I simply don't get why this didn't work, I'm sorry if this look idiot, but is better than don't asking.
.align 2
.thumb
main:
push {r0-r1,lr}
ldr r0, .pointer
ldr r1, .var
add r0, r0, r1
ldrh r0, [r0]
strh r0, [r1]
pop {r0-r1,pc}
.align 2
.pointer:
.word 0x020270B6 + (0x8004 * 2)
.var:
.word 0x020270B6 + (0x800D * 2)
You would store the pointer in variables 0x8004 and 0x8005, and then set variable 0x800D to a valor that would be added to the pointer in 0x8004 and 0x8005, after this, the routine would take the half-word in pointer2 (0x8004 0x8005 + 0x800D) and store it in 0x800D.
But the game simply crash, I'm putting +1 in the callasm.