Skip to content

Instantly share code, notes, and snippets.

@xigh
Created January 19, 2020 10:30
Show Gist options
  • Save xigh/86d0aca6f73cd02306850ddbfe219d19 to your computer and use it in GitHub Desktop.
Save xigh/86d0aca6f73cd02306850ddbfe219d19 to your computer and use it in GitHub Desktop.
I probably did something wrong ...
// -Wall -O2 -nostdlib -nostartfiles -ffreestanding -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mhard-float
void foobar()
{
uint8 buf[11] = { 0 };
for (int i = 0; i < sizeof(buf); i++)
{
uint8 x = buf[i];
uint32 a = (uint32) &buf[i];
uart_putx(a);
uart_putc(':');
uart_putc(' ');
uart_putx(x);
uart_putc('\n');
}
}
// 00007FE4: 00000000
// 00007FE5: 00000000
// 00007FE6: 00000000
// 00007FE7: 00000000
// 00007FE8: 00000000
// 00007FE9: 00000000
// 00007FEA: 00000000
// 00007FEB: 00000000
// 00007FEC: 00000020 <-- what the ... ??
// 00007FED: 0000009B <-- what the ... ??
// 00007FEE: 00000080
// 000081bc <foobar>:
// 81bc: e3a03000 mov r3, #0
// 81c0: e92d4070 push {r4, r5, r6, lr}
// 81c4: e24dd010 sub sp, sp, #16
// 81c8: e58d3008 str r3, [sp, #8]
// 81cc: e1a05003 mov r5, r3
// 81d0: e58d3004 str r3, [sp, #4]
// 81d4: e58d300b str r3, [sp, #11]
// 81d8: e28d4004 add r4, sp, #4
// 81dc: e28d600e add r6, sp, #14
// 81e0: ea000000 b 81e8 <foobar+0x2c>
// 81e4: e5f45001 ldrb r5, [r4, #1]!
// 81e8: e1a00004 mov r0, r4
// 81ec: eb0000a3 bl 8480 <uart_putx>
// 81f0: e3a0003a mov r0, #58 ; 0x3a
// 81f4: eb00007b bl 83e8 <uart_putc>
// 81f8: e3a00020 mov r0, #32
// 81fc: eb000079 bl 83e8 <uart_putc>
// 8200: e1a00005 mov r0, r5
// 8204: eb00009d bl 8480 <uart_putx>
// 8208: e3a0000a mov r0, #10
// 820c: eb000075 bl 83e8 <uart_putc>
// 8210: e1540006 cmp r4, r6
// 8214: 1afffff2 bne 81e4 <foobar+0x28>
// 8218: e28dd010 add sp, sp, #16
// 821c: e8bd8070 pop {r4, r5, r6, pc}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment