Files
Embedded-Hacking/WEEK10/slides/WEEK10-IMG08.svg
T
Kevin Thomas 6a9090915b Initial commit
2026-07-06 21:23:12 -04:00

102 lines
4.5 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"/>
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
<text class="title" x="600" y="52" text-anchor="middle">Branch Instructions</text>
<text class="dim" x="600" y="88" text-anchor="middle">How Conditionals Become Assembly</text>
<!-- Branch Instruction Table -->
<rect class="pnl" x="30" y="110" width="555" height="260" rx="8"/>
<text class="sub" x="50" y="150">ARM Branch Instructions</text>
<text class="amb" x="50" y="190">Instr</text>
<text class="amb" x="170" y="190">Meaning</text>
<text class="amb" x="440" y="190">Condition</text>
<line x1="50" y1="200" x2="565" y2="200" stroke="#1a1a2e" stroke-width="1"/>
<text class="grn" x="50" y="230">b</text>
<text class="txt" x="170" y="230">Branch always</text>
<text class="dim" x="440" y="230">Always</text>
<text class="grn" x="50" y="260">beq</text>
<text class="txt" x="170" y="260">Branch if Equal</text>
<text class="dim" x="440" y="260">Z flag set</text>
<text class="grn" x="50" y="290">bne</text>
<text class="txt" x="170" y="290">Branch if !=</text>
<text class="dim" x="440" y="290">Z flag clear</text>
<text class="grn" x="50" y="320">bgt</text>
<text class="txt" x="170" y="320">Branch if &gt;</text>
<text class="dim" x="440" y="320">Signed &gt;</text>
<text class="grn" x="50" y="350">blt</text>
<text class="txt" x="170" y="350">Branch if &lt;</text>
<text class="dim" x="440" y="350">Signed &lt;</text>
<!-- C to Assembly -->
<rect class="pnl" x="615" y="110" width="555" height="260" rx="8"/>
<text class="sub" x="635" y="150">C --> Assembly</text>
<text class="dim" x="635" y="182">C code:</text>
<rect x="635" y="192" width="515" height="60" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="txt" x="655" y="218">if (choice == 0x31)</text>
<text class="grn" x="675" y="243">printf("1");</text>
<text class="dim" x="635" y="280">Assembly:</text>
<rect x="635" y="290" width="515" height="70" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="cyn" x="655" y="318">cmp r4, #0x31</text>
<text class="dim" x="900" y="318">// compare</text>
<text class="cyn" x="655" y="346">bne skip_printf</text>
<text class="dim" x="900" y="346">// skip if !=</text>
<!-- Flow Diagram -->
<rect class="pnl" x="30" y="390" width="1140" height="180" rx="8"/>
<text class="sub" x="50" y="430">Conditional Branch Flow</text>
<rect x="50" y="450" width="230" height="42" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
<text class="cyn" x="165" y="478" text-anchor="middle">cmp r4, #0x31</text>
<line x1="280" y1="471" x2="320" y2="471" stroke="#888" stroke-width="2"/>
<rect x="325" y="450" width="270" height="42" rx="6" fill="#0a0a0f" stroke="#ffaa00"/>
<text class="amb" x="460" y="478" text-anchor="middle">beq target_addr</text>
<line x1="595" y1="460" x2="650" y2="460" stroke="#00ff41" stroke-width="2"/>
<text class="grn" x="660" y="464">r4==0x31: JUMP</text>
<line x1="440" y1="492" x2="440" y2="515" stroke="#ff0040" stroke-width="2"/>
<text class="red" x="465" y="515">r4!=0x31: continue next</text>
<text class="dim" x="50" y="548">cmp sets CPU flags, branch reads them</text>
<!-- NOP Encoding -->
<rect class="pnl" x="30" y="590" width="555" height="170" rx="8"/>
<text class="sub" x="50" y="630">NOP (No Operation)</text>
<text class="txt" x="50" y="665">ARM Thumb NOP:</text>
<text class="grn" x="320" y="665">00 bf</text>
<text class="dim" x="420" y="665">2 bytes</text>
<text class="txt" x="50" y="700">Wide NOP:</text>
<text class="grn" x="320" y="700">00 f0 00 80</text>
<text class="dim" x="50" y="730">Replaces 4-byte bl instruction</text>
<!-- Hacking Branches -->
<rect class="pnl" x="615" y="590" width="555" height="170" rx="8"/>
<text class="sub" x="635" y="630">Hacking Branches</text>
<text class="txt" x="635" y="665">Change branch target addr</text>
<text class="dim" x="635" y="690">Redirect program flow</text>
<text class="txt" x="635" y="715">NOP out instructions</text>
<text class="dim" x="635" y="740">Erase code silently</text>
</svg>