Ground Embedded KO Subscribe

Roadmap / Firmware

Machine Code & Assembly

When a hard fault hits or the optimizer rewrites your code, machine code is what you end up reading.

Goal Follow what happens from reset to main().

  1. 01
    What an instruction is

    Machine code is the numbers the CPU reads; assembly is the names for those numbers.

    Read the note KR

  2. 02
    Reading Thumb instructions

    MOV, LDR, STR, B and BL on ARM Cortex-M.

    Read the note KR

  3. 03
    Registers and calling convention

    Arguments in r0 to r3, return address in lr, stack position in sp.

    Read the note KR

  4. 04
    C versus assembly

    Disassembling a small C function line by line and comparing optimization levels.

    Read the note KR

  5. 05
    Startup code

    .data is copied to RAM and .bss zeroed before main is called.

    Read the note KR

  6. 06
    Linker scripts and sections

    The file that decides where .text, .data and .bss sit in Flash and RAM.

    Read the note KR

  7. 07
    Vector table

    The table holding the initial stack value and the handler addresses.

    Read the note KR

  8. 08
    Hard-fault analysis

    Finding the failing line from the registers left on the stack.

    Read the note KR