I am viewing the assembly output of this function:
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);
}
And it looks like this:
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
I am completely puzzled on where the copying from .L4 to the stack happens?
I see the stack pointer getting moved by 16B, and I see the adds instruction for '0'+x, but which instruction copies the data?
Sorry for the newbie question, thanks!