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().

  • IntermediateLevel
  • about 2 weeksat one hour a day
  • 8topics
  • 0labs
  1. 01
    What an instruction is

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

    Read the note →

  2. 02
    Reading Thumb instructions

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

    Read the note →

  3. 03
    Registers and calling convention

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

    Read the note →

  4. 04
    C versus assembly

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

    Read the note →

  5. 05
    Startup code

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

    Read the note →

  6. 06
    Linker scripts and sections

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

    Read the note →

  7. 07
    Vector table

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

    Read the note →

  8. 08
    Hard-fault analysis

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

    Read the note →

CHECK TASK

Disassemble and read one C function

Compile a short C function, disassemble it and annotate which part of the C each line is.

If you can tick all three, move on to the next subject. Ticks are saved in this browser only.