I'm having trouble deciphering this block of assembly code. What would the value of r1 be by the end and how would I get there?
我很难破译这段汇编代码。r1的值会是多少呢?
3242ba66 f6454118 movw r1, 0x5c18
3242ba6a 466f mov r7, sp
3242ba6c f6c0415a movt r1, 0xc5a
3242ba70 f2460002 movw r0, 0x6002
3242ba74 f6c0405a movt r0, 0xc5a
3242ba78 4479 add r1, pc
3242ba7a 4478 add r0, pc
3242ba7c 6809 ldr r1, [r1, #0]
1 个解决方案
#1
26
movw
followed by a movt
is a common way to load a 32-bit value into a register. It's the equivalent of OR-ing those two immediate values together, with the movt
being the upper 16-bit. In this case, r1 = (movt immediate value << 16) | (movw immediate value))
.
movw后面是movt,这是将32位值加载到寄存器中的常用方法。它相当于把两个直接的值连在一起,而movt是上16位。在本例中,r1 = (movt立即值<< 16)| (movw立即值))。
3242ba66 f6454118 movw r1, 0x5c18 // r1 = 0x5c18
3242ba6a 466f mov r7, sp
3242ba6c f6c0415a movt r1, 0xc5a // r1 = (r1 & 0xffff) | (0xc5a << 16)
3242ba70 f2460002 movw r0, 0x6002
3242ba74 f6c0405a movt r0, 0xc5a
3242ba78 4479 add r1, pc // r1 = r1 + pc
3242ba7a 4478 add r0, pc
3242ba7c 6809 ldr r1, [r1, #0] // r1 = *(r1 + 0)
#1
26
movw
followed by a movt
is a common way to load a 32-bit value into a register. It's the equivalent of OR-ing those two immediate values together, with the movt
being the upper 16-bit. In this case, r1 = (movt immediate value << 16) | (movw immediate value))
.
movw后面是movt,这是将32位值加载到寄存器中的常用方法。它相当于把两个直接的值连在一起,而movt是上16位。在本例中,r1 = (movt立即值<< 16)| (movw立即值))。
3242ba66 f6454118 movw r1, 0x5c18 // r1 = 0x5c18
3242ba6a 466f mov r7, sp
3242ba6c f6c0415a movt r1, 0xc5a // r1 = (r1 & 0xffff) | (0xc5a << 16)
3242ba70 f2460002 movw r0, 0x6002
3242ba74 f6c0405a movt r0, 0xc5a
3242ba78 4479 add r1, pc // r1 = r1 + pc
3242ba7a 4478 add r0, pc
3242ba7c 6809 ldr r1, [r1, #0] // r1 = *(r1 + 0)