First I wanted to just copy the intire 4 byte long word with both the id and the secret one, But the compiler wouldn't let me do that since the offset had to be a multiplication of &h4, I couldn't do that (But if there is a solution where I could do some thing like that please tell me.)
So then I decided to both parts seperatly, But since the ID was stored in the last two bytes of a word and I didn't know how to only get the last part of the word, I copyed the intiere word to to variables (&h800A and &h800B) Which emptys the 800A with zeros.
To get the secret ID I allmost did excatly like you did, except I changed the offset a bit.
The thing I spended most time on was finding the location of the vars, I just thought they were in order (like 800B, 800C, 800D) and not storred in that random way.
Here's my code.
Code:
.text
.align 2
.thumb
.thumb_func
.global lesson1
main:
push {r0-r1, lr}
ldr r0, .PLAYER_DATA
ldr r0, [r0]
ldr r1, .VAR
ldr r0, [r0, #0x8]
str r0, [r1]
ldr r0, .PLAYER_DATA
ldr r0, [r0]
ldrh r0, [r0, #0xC]
strh r0, [r1, #0x4]
pop {r0-r1, pc}
.align 2
.PLAYER_DATA:
.word 0x0300500C
.VAR:
.word 0x020370CC
Is it aproved? (I mean, I filled the 0x800A with zeros.:nervous:)
If I was aloud to use other registers I would propperly just have saved the data location offset, and save a bit space / time there.
Edit: I just tryed fixing my routine, and first I just used the var 800A instead of 800D for the secret ID since I had to use to vars for the normal one at first anyway...
Next I tryed using the third register instead of emptying the first one and reload the first offet again.
Code:
push {r0-r1-[B]r2[/B], lr}
ldr r0, .Var1
ldr r0, [r0]
ldr r1, .Var2
ldr [B]r2[/B], [r0, #0x8]
str [B]r2[/B], [r1]
ldrh r0, [r0, #0xC]
strh r0, [B][r1][/B]
pop {r0-r1-[B]r2[/B], pc}
Was it a good idea to use the register 2?