Thread: [Tutorial] GBA ASM Programming View Single Post
#50
January 6th, 2011 (7:37 PM).
 NintendoBoyDX Join Date: Jul 2010 Gender: Male Posts: 94
Thanks Xenesis, colcolstyles. There was just one more thing that wasn't clear to me:
.word 0x020270B6 + (0x800D * 2)
If the 0x8000-0x8013 variables are the only static one, how would there be an address of the "first" variable(I assume 0x0000), wouldn't it be DMA along with the rest?

BTW, looking at an example code from a tutorial JPAN posted a while ago, he subtracts 0x8000 from his variable values, multiplies them by 4, then finally adds that to the 0x8000 variable's address. I don't understand why it would be necessary to do that(or how that works quite frankly), even though with the code in this tutorial you can simply store the value to loaded variable.
Here was the code:
Code:
.align 2
.thumb
Ldrh r0, [r0, #0x0]      @and this will load its content.
Ldrh r1, [r1, #0x0]      @both variable numbers are loaded
Lsl r2, r2, #0x10          @cleans the bottom half of register r2
Add r2, r2,#0x8          @places 0x8 in r2
Lsl r2, r2, #0xc            @and this turns 0x8 in 0x8000, and cleans the rest                                                               @of r2
Sub r1, r1, r2               @leaves only the last value in
Sub r0, r0, r2               @each variable.
Lsl r1, r1, #0x2            @after multiplied by 4, It becomes the
Lsl r0, r0, #0x2            @same here.
Ldrh r2, [r0, #0x0]      @now we load the content of the variables we
Ldrh r1, [r1, #0x0]      @want to add
Strh r2, [r0, #0x0]       @the result, that is in r2, is placed in the first                                                                        @variable, the one in 0x8013
Pop {r0-r2, pc}           @and we’re done