mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-07-12 23:26:33 +02:00
79 lines
3.6 KiB
XML
79 lines
3.6 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">Two's Complement</text>
|
|
<text x="600" y="88" text-anchor="middle" class="dim">How Negative Numbers are Stored</text>
|
|
|
|
<!-- Step-by-step: -42 encoding -->
|
|
<rect x="40" y="110" width="1120" height="280" rx="8" class="pnl"/>
|
|
<text x="600" y="148" text-anchor="middle" class="sub">Encoding -42 as int8_t</text>
|
|
|
|
<rect x="60" y="170" width="340" height="90" rx="6" fill="#0a0a0f" stroke="#00d4ff" stroke-width="1"/>
|
|
<text x="230" y="200" text-anchor="middle" class="cyn">Step 1: Start</text>
|
|
<text x="230" y="235" text-anchor="middle" class="txt">42 = 0x2A</text>
|
|
|
|
<rect x="420" y="170" width="340" height="90" rx="6" fill="#0a0a0f" stroke="#ffaa00" stroke-width="1"/>
|
|
<text x="590" y="200" text-anchor="middle" class="amb">Step 2: Flip</text>
|
|
<text x="590" y="235" text-anchor="middle" class="txt">~0x2A = 0xD5</text>
|
|
|
|
<rect x="780" y="170" width="340" height="90" rx="6" fill="#0a0a0f" stroke="#00ff41" stroke-width="1"/>
|
|
<text x="950" y="200" text-anchor="middle" class="grn">Step 3: Add 1</text>
|
|
<text x="950" y="235" text-anchor="middle" class="txt">0xD5+1 = 0xD6</text>
|
|
|
|
<text x="60" y="300" class="txt">Binary:</text>
|
|
<text x="200" y="300" class="grn">00101010</text>
|
|
<text x="400" y="300" class="amb">-></text>
|
|
<text x="450" y="300" class="amb">11010101</text>
|
|
<text x="650" y="300" class="grn">-></text>
|
|
<text x="700" y="300" class="red">11010110</text>
|
|
|
|
<text x="60" y="340" class="dim">Result: -42 stored as 0xD6 in memory</text>
|
|
<text x="60" y="368" class="dim">Top bit = 1 means negative</text>
|
|
|
|
<!-- Comparison Table -->
|
|
<rect x="40" y="410" width="1120" height="200" rx="8" class="pnl"/>
|
|
<text x="600" y="448" text-anchor="middle" class="sub">Signed vs Unsigned: Same Bits!</text>
|
|
|
|
<text x="80" y="488" class="cyn">Hex</text>
|
|
<text x="280" y="488" class="cyn">Binary</text>
|
|
<text x="580" y="488" class="cyn">uint8_t</text>
|
|
<text x="800" y="488" class="cyn">int8_t</text>
|
|
|
|
<line x1="60" y1="500" x2="1140" y2="500" stroke="#1a1a2e" stroke-width="1"/>
|
|
|
|
<text x="80" y="530" class="amb">0x2A</text>
|
|
<text x="280" y="530" class="txt">00101010</text>
|
|
<text x="580" y="530" class="grn">42</text>
|
|
<text x="800" y="530" class="grn">42</text>
|
|
|
|
<text x="80" y="565" class="amb">0xD6</text>
|
|
<text x="280" y="565" class="txt">11010110</text>
|
|
<text x="580" y="565" class="grn">214</text>
|
|
<text x="800" y="565" class="red">-42</text>
|
|
|
|
<text x="60" y="590" class="dim">Same byte 0xD6 = 214 unsigned, -42 signed</text>
|
|
|
|
<!-- GDB Verification -->
|
|
<rect x="40" y="630" width="1120" height="150" rx="8" class="pnl"/>
|
|
<text x="600" y="668" text-anchor="middle" class="sub">GDB Verification</text>
|
|
|
|
<rect x="60" y="688" width="1080" height="75" rx="6" fill="#0a0a0f" stroke="#00ff41" stroke-width="1"/>
|
|
<text x="80" y="718" class="grn">(gdb)</text>
|
|
<text x="180" y="718" class="txt">x/1xb &range</text>
|
|
<text x="80" y="745" class="amb">0x200003e7:</text>
|
|
<text x="300" y="745" class="red">0xd6</text>
|
|
<text x="440" y="745" class="dim">// -42 in memory</text>
|
|
</svg> |