Files
Kevin Thomas 6a9090915b Initial commit
2026-07-06 21:23:12 -04:00

86 lines
4.0 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">Struct Memory Layout</text>
<text class="dim" x="600" y="88" text-anchor="middle">How Structs Are Stored and Accessed</text>
<!-- Memory Layout Table -->
<rect class="pnl" x="30" y="110" width="1140" height="280" rx="8"/>
<text class="sub" x="50" y="150">Memory Layout (6 bytes total)</text>
<text class="amb" x="50" y="190">Address</text>
<text class="amb" x="230" y="190">Member</text>
<text class="amb" x="500" y="190">Size</text>
<text class="amb" x="650" y="190">Value</text>
<line x1="50" y1="200" x2="1140" y2="200" stroke="#1a1a2e" stroke-width="1"/>
<text class="cyn" x="50" y="230">0x20000000</text>
<text class="txt" x="250" y="230">led1_pin</text>
<text class="dim" x="500" y="230">1 byte</text>
<text class="grn" x="680" y="230">16 (0x10)</text>
<text class="cyn" x="50" y="260">0x20000001</text>
<text class="txt" x="250" y="260">led2_pin</text>
<text class="dim" x="500" y="260">1 byte</text>
<text class="grn" x="680" y="260">17 (0x11)</text>
<text class="cyn" x="50" y="290">0x20000002</text>
<text class="txt" x="250" y="290">led3_pin</text>
<text class="dim" x="500" y="290">1 byte</text>
<text class="grn" x="680" y="290">18 (0x12)</text>
<text class="cyn" x="50" y="320">0x20000003</text>
<text class="txt" x="250" y="320">led1_state</text>
<text class="dim" x="500" y="320">1 byte</text>
<text class="txt" x="680" y="320">0 (false)</text>
<text class="cyn" x="50" y="350">0x20000004</text>
<text class="txt" x="250" y="350">led2_state</text>
<text class="dim" x="500" y="350">1 byte</text>
<text class="txt" x="680" y="350">0 (false)</text>
<text class="cyn" x="50" y="380">0x20000005</text>
<text class="txt" x="250" y="380">led3_state</text>
<text class="dim" x="500" y="380">1 byte</text>
<text class="txt" x="680" y="380">0 (false)</text>
<!-- Dot Operator -->
<rect class="pnl" x="30" y="410" width="555" height="170" rx="8"/>
<text class="sub" x="50" y="450">Dot Operator ( . )</text>
<text class="dim" x="50" y="478">Use with struct variable</text>
<rect x="50" y="492" width="515" height="70" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="txt" x="70" y="520">leds.led1_pin = 16;</text>
<text class="txt" x="70" y="548">leds.led1_state = true;</text>
<!-- Arrow Operator -->
<rect class="pnl" x="615" y="410" width="555" height="170" rx="8"/>
<text class="sub" x="635" y="450">Arrow Operator ( -> )</text>
<text class="dim" x="635" y="478">Use with pointer to struct</text>
<rect x="635" y="492" width="515" height="70" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="txt" x="655" y="520">ptr->led1_pin = 16;</text>
<text class="dim" x="655" y="548">// same as (*ptr).led1_pin</text>
<!-- Designated Initializer -->
<rect class="pnl" x="30" y="600" width="1140" height="160" rx="8"/>
<text class="sub" x="50" y="640">Designated Initializers</text>
<rect x="50" y="655" width="740" height="85" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="cyn" x="70" y="683">simple_led_ctrl_t leds = {</text>
<text class="grn" x="100" y="713">.led1_pin = 16, .led2_pin = 17, .led3_pin = 18</text>
<text class="cyn" x="70" y="730">};</text>
<text class="dim" x="820" y="690">Clear which value goes</text>
<text class="dim" x="820" y="715">to which member</text>
<text class="dim" x="820" y="740">Order doesn't matter</text>
</svg>