I’m working with a disassembled ARMv7 binary. There are several instances where groups of instructions seem sub-optimal, but this one really caught my attention:
00009086 movw r3, #0x4f36
0000908a movt r3, #0x1 ; ledTimer
0000908e ldrh r3, [r3] ; ledTimer
00009090 subs r3, #0x1
00009092 uxth r2, r3
00009094 movw r3, #0x4f36
00009098 movt r3, #0x1 ; ledTimer
0000909c strh r2, [r3] ; ledTimer
0000909e movw r3, #0x4f36
000090a2 movt r3, #0x1 ; ledTimer
000090a6 ldrh r3, [r3] ; ledTimer
000090a8 cmp r3, #0x0
000090aa bne.w loc_9250
Since loc_9250
is the beginning of the epilogue, I interpreted this section as:
if (--ledTimer != 0) {
return;
}
Am I missing something about the ARMv7 architecture that makes all these instructions necessary (besides my disassembler not substituting the pseudo-mov32
for the movw
/movt
pairs)? It seems like a very inefficient way of going about this sequence of operations. Or perhaps this is just the result of a compiler with optimisation settings cranked right down.