This routine looks completely broken to me, I'm surprised it doesn't crash all the time. Maybe try this :
.text
.align 2
.thumb
.thumb_func
.global setflagevo
main:
push {r0-r7}
add r0, r6, r7
lsl r0, r0, #0x3
add r0, r2, r0
add r3, r0, r3
ldrh r2, [r3, #0x2]
mov r0, r8 @ THIS is...