mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-07-06 20:47:55 +02:00
65 lines
3.4 KiB
XML
65 lines
3.4 KiB
XML
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
|
|
<style>
|
|
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
|
|
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
|
|
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
|
|
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
|
|
.dim{font:20px 'Courier New',monospace;fill:#888}
|
|
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
|
|
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
|
|
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
|
|
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
|
|
.badge{stroke:#00ff41;rx:14}
|
|
</style>
|
|
<rect class="bg" width="1200" height="800"/>
|
|
|
|
<!-- Title -->
|
|
<text x="600" y="52" text-anchor="middle" class="title">Compiler Optimizations</text>
|
|
<text x="600" y="88" text-anchor="middle" class="dim">What the compiler does to your code</text>
|
|
|
|
<!-- Optimization 1: Regular var removed -->
|
|
<rect x="40" y="110" width="1120" height="220" rx="8" class="pnl"/>
|
|
<text x="600" y="148" text-anchor="middle" class="sub">Optimization 1: Dead Code Removal</text>
|
|
|
|
<rect x="60" y="170" width="500" height="135" rx="4" fill="#0a0a0f" stroke="#ff0040" stroke-width="1"/>
|
|
<text x="80" y="200" class="red">Your code:</text>
|
|
<text x="80" y="230" class="txt">uint8_t reg = 42;</text>
|
|
<text x="80" y="260" class="txt">reg++;</text>
|
|
<text x="80" y="285" class="dim">// No lasting effect!</text>
|
|
|
|
<rect x="620" y="170" width="520" height="135" rx="4" fill="#0a0a0f" stroke="#00ff41" stroke-width="1"/>
|
|
<text x="640" y="200" class="grn">Compiler output:</text>
|
|
<text x="640" y="230" class="amb">movs r1, #42</text>
|
|
<text x="640" y="260" class="dim">// reg++ is GONE</text>
|
|
<text x="640" y="285" class="dim">// Uses constant 42 directly</text>
|
|
|
|
<!-- Optimization 2: Function Inlining -->
|
|
<rect x="40" y="350" width="1120" height="200" rx="8" class="pnl"/>
|
|
<text x="600" y="388" text-anchor="middle" class="sub">Optimization 2: Function Inlining</text>
|
|
|
|
<rect x="60" y="410" width="500" height="110" rx="4" fill="#0a0a0f" stroke="#ff0040" stroke-width="1"/>
|
|
<text x="80" y="440" class="red">Your code:</text>
|
|
<text x="80" y="470" class="txt">gpio_pull_up(15);</text>
|
|
<text x="80" y="500" class="dim">// Simple wrapper func</text>
|
|
|
|
<rect x="620" y="410" width="520" height="110" rx="4" fill="#0a0a0f" stroke="#00ff41" stroke-width="1"/>
|
|
<text x="640" y="440" class="grn">Compiler output:</text>
|
|
<text x="640" y="470" class="amb">gpio_set_pulls(15,1,0);</text>
|
|
<text x="640" y="500" class="dim">// Inlined to real func</text>
|
|
|
|
<!-- Optimization 3: Instruction Scheduling -->
|
|
<rect x="40" y="570" width="1120" height="210" rx="8" class="pnl"/>
|
|
<text x="600" y="608" text-anchor="middle" class="sub">Optimization 3: Scheduling</text>
|
|
|
|
<text x="60" y="648" class="txt">Compiler reorders instructions</text>
|
|
<text x="60" y="678" class="txt">to avoid pipeline stalls:</text>
|
|
|
|
<rect x="60" y="698" width="340" height="55" rx="4" fill="#0a0a0f" stroke="#00d4ff" stroke-width="1"/>
|
|
<text x="230" y="732" text-anchor="middle" class="cyn">Load SIO base</text>
|
|
|
|
<rect x="420" y="698" width="340" height="55" rx="4" fill="#0a0a0f" stroke="#ffaa00" stroke-width="1"/>
|
|
<text x="590" y="732" text-anchor="middle" class="amb">Increment s</text>
|
|
|
|
<rect x="780" y="698" width="340" height="55" rx="4" fill="#0a0a0f" stroke="#00ff41" stroke-width="1"/>
|
|
<text x="950" y="732" text-anchor="middle" class="grn">Read GPIO</text>
|
|
</svg> |