当程序完成最后一行时,它会将寄存器r0设置为0

时间:2015-03-02 11:59:47

标签: assembly arm

我的程序结尾处的代码如下:

        ldrb r2, [r1, #12] 
        sub r2, r2, #48
        cmp r2, r7 
        beq Check
        sub r0, r0, #1
Check   add r0, #1

END

如果是cmp r2,则r7决定r2& r7相等,程序跳转到Check应该是预期的。然而,奇怪的是,在r1添加了#1之后,它被设置为0.调试器在反汇编中显示以下内容:

0x00000088 E1A00000 NOP
that above line has a green icon to the left.
0x0000008C 30313338 EORCCS R3,R1,R8,LSR R3
0x00000090 30303135 EORCCS R3,R0,R5,LSR R1
0x00000094 30373338 EORCCS R3,R7,R8,LSR R3
the above three lines has an orange icon to the left.
0x00000098 0000008C ANDEQ R0,R0,R12,LSL #1
the above line has a light blue icon to the left.

如何阻止这种情况发生? (运行ARM7(Big Endian))

0 个答案:

没有答案