我正在查看此函数的汇编输出:
extern void write(char * buff);
void test(int x)
{
// copy "EXAMPLE\0\0\0\0\0..."
char buff[16] = "EXAMPLE";
// set byte 10 to '0'+x
buff[10] = '0' + x;
// write
write(buff);
}
它看起来像这样:
test:
push {r4, lr}
ldr r2, .L4
mov r3, r0
ldm r2, {r0, r1}
sub sp, sp, #16
mov r2, sp
adds r3, r3, #48
stm r2, {r0, r1}
movs r4, #0
mov r0, r2
strd r4, r4, [sp, #8]
strb r3, [sp, #10]
bl write
add sp, sp, #16
pop {r4, pc}
.L4:
.word .LANCHOR0
.cfi_endproc
.LFE0:
.size test, .-test
.section .rodata
.align 2
.set .LANCHOR0,. + 0
.ascii "EXAMPLE\000"
.space 8
.text
我完全不知道从哪里复制.L4
到堆栈?
我看到堆栈指针被移动了 16B,并且我看到了 的adds
指令'0'+x
,但是哪条指令复制了数据?
抱歉新手问题,谢谢!