# Hackaday tip draft - asmdiff - Claude initial draft

**Mechanics:** Hackaday doesn't take direct posts - you send a tip and an editor
decides whether to write it up. Use their "Submit a Tip" form or email
`tips@hackaday.com`. Treat this as a pitch, not a finished article; lead with the
hardware angle and the concrete story, because that's what they bite on. Make
sure the repo is push-current and PyPI 0.2.0 is live before sending.

## Subject

```
asmdiff - see what your C actually compiles to on the chip (and catch silent softfloat / software-divide calls)
```

## Body

Hi Hackaday,

I built a small terminal tool embedded folks might get a kick out of: asmdiff, a
per-function assembly differ for C.

The itch: you rewrite a hot function on an MCU to make it faster, but nothing in
the compiler warnings tells you whether it worked - whether a float expression
quietly pulled in a softfloat routine, or a 64-bit divide became a __udivdi3
software-divide loop. The assembly knows; you usually don't look, too much work. asmdiff makes
that a one-liner: it compiles a function (or a whole file) and prints a summary
whose `calls` column flags exactly those hidden library calls, with the
side-by-side assembly as evidence.

The embedded-specific bits:

- Run one source across a matrix of cross-toolchains at once - e.g. esp32 /
  esp32s2 / esp32s3 - borrowing the real include/define flags from your build's
  compile_commands.json. Watch the FPU-less esp32-S2 sprout softfloat conversion
  calls its siblings don't emit, side by side, with no separate build trees.
- Point it at a shipped .elf and it disassembles through the toolchain's objdump
  to show what actually survived LTO and linking, not the idealized single-file
  -S output.

It came out of chasing codegen in a synthesizer firmware, where it found a 2 kHz
timer callback quietly running a softfloat divide plus a 64-bit integer divide -
which also turned out to hide a clock-counter overflow bug. That find is written
up in the README.

It's one stdlib-only Python file, no dependencies, MIT-licensed. Repo, with GIFs
and a worked example: https://github.com/rt-rtos/asmdiff

Happy to answer anything, and thanks for taking a look.

- Rasmus

---

## My Edits

Hi Hackaday,\
\
I built a small terminal tool embedded folks might get a kick out of: asmdiff, a\
per-function assembly differ for C.\
\
The itch: you rewrite a hot function on an MCU to make it faster, but nothing in\
the compiler warnings tells you whether it worked - whether a float expression\
quietly pulled in a softfloat routine, or a 64-bit divide became a \_\_udivdi3\
software-divide loop. The assembly knows; you usually don't look - too much work.



 asmdiff makes that a one-liner: it compiles a function (or a whole file) and prints a summary

whose \`calls\` column flags exactly those hidden library calls, with the\
side-by-side assembly as evidence.



This can be the ace up your sleeve in the next heated folklore debate about what compiles to the optimal assembly in exactly this toolchain and context.\
\
The embedded-specific bits:



* Parses xtensa, arm, riscv, x86 assembly
* Sanity check across git worktrees with whole-file instruction count and loop span summaries.

*  Run one source across a matrix of cross-toolchains at once - e.g. esp32 /  esp32s2 / esp32s3 - borrowing the real include/define flags from your build's compile\_commands.json. Watch the FPU-less esp32-S2 sprout softfloat conversion calls its siblings don't emit, side by side, with no separate build trees.
* Point it at a shipped .elf and it disassembles through the toolchain's objdump to show what actually survived LTO and linking, not the idealized single-file -S output.

It came out of chasing hot-path micro-optimizations in the shorepine/amy synth engine, where it found a 2 kHz timer callback quietly running a softfloat divide plus a 64-bit integer divide -\
which also turned out to hide a clock-counter overflow bug among other things.

That find is written up in the README.\
\
It's one stdlib-only Python file, no dependencies, MIT-licensed. Repo, with GIFs\
and a worked example: https://github.com/rt-rtos/asmdiff



It can be tried without installing via: **uvx asmdiff&#x20;**&#x6F;&#x72;**&#x20;pipx run asmdiff**\
\
Happy to answer anything, and thanks for taking a look.\
\
\- Rasmus
