我有一个推/弹计数似乎不匹配的功能。这是正常的吗?
disassemble /m
Dump of assembler code for function TouchState::GetModifierKeys() const:
141 {
0x5d718b64 <+0>: push {r0, r1, r2, r3, r4, lr}
142 Grip<TouchStateImpl> grip_this;
143
144 Impl::SureGetGrip(*this, grip_this);
0x5d718b68 <+4>: movs r2, #128 ; 0x80
0x5d718b6a <+6>: mov r1, sp
0x5d718b70 <+12>: lsls r2, r2, #18
0x5d718b7e <+26>: bl 0x5d718984 <Impl::SureGetGrip<TouchStateImpl>(Object const&, Grip<TouchStateImpl>&, int)>
145 if(grip_this->valid_flags.any(TouchStateImpl::modifier_keys_valid))
0x5d718b84 <+32>: ldr r1, [pc, #84] ; (0x5d718bdc <TouchState::GetModifierKeys() const+120>)
0x5d718b86 <+34>: adds r0, r4, #0
0x5d718b88 <+36>: add r1, pc
0x5d718b8a <+38>: adds r0, #40 ; 0x28
0x5d718b8c <+40>: ldr r1, [r1, #0]
0x5d718b8e <+42>: bl 0x5d67d55c <Extended_Bitfield<7558u, unsigned int, 1u>::any(Extended_Bitfield_Constant<7558u, unsigned int, 1u> const&) const>
0x5d718b92 <+46>: cmp r0, #0
0x5d718b94 <+48>: beq.n 0x5d718ba4 <TouchState::GetModifierKeys() const+64>
146 return grip_this->modifier_keys;
0x5d718b96 <+50>: adds r4, #112 ; 0x70
0x5d718b98 <+52>: ldrh r4, [r4, #0]
147 else
148 throw InvalidObjectException();
0x5d718b9a <+54>: mov r0, sp
0x5d718b9c <+56>: bl 0x5d718a64 <Grip<TouchStateImpl>::~Grip()>
0x5d718ba4 <+64>: movs r0, #8
0x5d718ba6 <+66>: blx 0x5da2eac8
0x5d718baa <+70>: ldr r1, [pc, #52] ; (0x5d718be0 <TouchState::GetModifierKeys() const+124>)
0x5d718bac <+72>: adds r4, r0, #0
0x5d718bae <+74>: add r1, pc
0x5d718bb0 <+76>: bl 0x5d646da4 <InvalidObjectException::InvalidObjectException(char const*)>
0x5d718bb4 <+80>: ldr r1, [pc, #44] ; (0x5d718be4 <TouchState::GetModifierKeys() const+128>)
0x5d718bb6 <+82>: ldr r2, [pc, #48] ; (0x5d718be8 <TouchState::GetModifierKeys() const+132>)
0x5d718bb8 <+84>: adds r0, r4, #0
0x5d718bba <+86>: add r1, pc
0x5d718bbc <+88>: add r2, pc
0x5d718bbe <+90>: ldr r1, [r1, #0]
0x5d718bc0 <+92>: ldr r2, [r2, #0]
0x5d718bc2 <+94>: blx 0x5da2eaf8
0x5d718bc6 <+98>: adds r0, r4, #0
0x5d718bc8 <+100>: blx 0x5da2eb04
0x5d718bcc <+104>: b.n 0x5d718bce <TouchState::GetModifierKeys() const+106>
0x5d718bce <+106>: mov r0, sp
0x5d718bd0 <+108>: bl 0x5d718a64 <Grip<TouchStateImpl>::~Grip()>
0x5d718bd4 <+112>: blx 0x5da2ea4c
0x5d718bd8 <+116>: subseq r12, pc, r0, ror pc ; <UNPREDICTABLE>
0x5d718bdc <+120>: subseq r12, pc, r8, asr #15
0x5d718be0 <+124>: umaaleq pc, r9, r12, r12 ; <UNPREDICTABLE>
0x5d718be4 <+128>: subseq r11, pc, lr, lsl r9 ; <UNPREDICTABLE>
0x5d718be8 <+132>: subseq r11, pc, r0, lsr #18
149 }
0x5d718ba0 <+60>: adds r0, r4, #0
0x5d718ba2 <+62>: pop {r1, r2, r3, r4, pc}
这是来自发布版本,从此函数返回时发生崩溃。它返回的类/结构只包含short
(2个字节)。如果我将结构更改为包含int
,则不会发生崩溃。
我刚刚开始学习ARM asm,并了解了lr寄存器。我看了另一个函数,推/弹对计数匹配。在这种情况下,有6个寄存器被推送,5个弹出。为了使事情更加混乱,当我做出返回结构大小int
时,反汇编就会有:
0x5d718b4c <+0>: push {r0, r1, r2, r3, r4, lr}
0x5d718b9e <+82>: pop {r4, pc}
所以,我不确定我是否只是在其他地方推动(或弹出:p)问题。
此外,我从这个网站上读到pops
确实是LDMIA SP!,{...}
,但我没有看到该操作码。