RodrigoDornelles / 3bc-lang

Low-level language, tiny virtual machine, minimal runtime, intermediate representation, embeddable, easy for beginners. (Friendly Punched cards)
https://3bc-lang.org
GNU General Public License v3.0
238 stars 26 forks source link

use graphviz to explain stack memory #404

Open RodrigoDornelles opened 1 year ago

RodrigoDornelles commented 1 year ago
digraph g {
    graph [
        rankdir = "LR",
        ranksep = 1.5
    ];
    "node0" [
        label = "Stack Memory | <SM> 0xf7fc4380",
        shape = "record"
    ];
    "node1" [
        label = "Stack Buffer | <ST> ST 16 | <SP> SP 12 | <CFG1> | <CFG2> | <CFG3> | <SS1> SS 5 | PC | <SS2> SS 1 | PC | <DATA1> | <DATA2> | <SS3> SS 3 | <FREE1> | <FREE2> | <FREE3> | <FREE4>",
        shape = "record"
    ];
    "comment1" [
        label = "program memory config",
        shape = "note"
    ];
    "comment2" [
        label = "heap memory config",
        shape = "note"
    ];
    "comment3" [
        label = "interpreter config",
        shape = "note"
    ];
    "comment4" [
        label = "data",
        shape = "note"
    ];
    "comment5" [
        label = "free",
        shape = "note"
    ];
    "comment6" [
        label = "stack head",
        shape = "note"
    ];
    "comment7" [
        label = "stack tail",
        shape = "note"
    ];
    "node0":SM -> "node1":ST [];
    "node1":SP:e -> "node1":SS3:e [];
    "node1":SS1 -> "node1":ST:n [];
    "node1":SS2 -> "node1":SS1 [];
    "node1":SS3 -> "node1":SS2 [];
    "node1":ST:e -> "node1":FREE4:e [];
    "comment1" -> "node1":CFG1 [style="dotted", weight=0, arrowhead="none"];
    "comment2" -> "node1":CFG2 [style="dotted", weight=0, arrowhead="none"];
    "comment3" -> "node1":CFG3 [style="dotted", weight=0, arrowhead="none"];
    "comment4" -> "node1":DATA1 [style="dotted", weight=0, arrowhead="none"];
    "comment4" -> "node1":DATA2 [style="dotted", weight=0, arrowhead="none"];
    "comment5" -> "node1":FREE1 [style="dotted", weight=0, arrowhead="none"];
    "comment5" -> "node1":FREE2 [style="dotted", weight=0, arrowhead="none"];
    "comment5" -> "node1":FREE3 [style="dotted", weight=0, arrowhead="none"];
    "comment5" -> "node1":FREE4 [style="dotted", weight=0, arrowhead="none"];
    "node1":ST ->"comment6" [style="dotted", weight=0, arrowhead="none"];
    "node1":FREE4 ->"comment7" [style="dotted", weight=0, arrowhead="none"];
    "node1":FREE4 -> "legend" [style="invis"];
    "legend" [
        label = <<table cellspacing="0" cellpadding="4" border="0" cellborder="1" style="rounded">
                        <tr><td colspan="2" bgcolor="lightgray"><b>Legend</b></td></tr>
                        <tr><td>PC</td><td>program counter</td></tr>
                        <tr><td>SS</td><td>Stack Size</td></tr>
                        <tr><td>SP</td><td>Stack Pointer</td></tr>
                        <tr><td>ST</td><td>Stack Tail</td></tr>
                    </table>>,
        shape = "plaintext",
        style = "filled",
        fillcolor = "white",
        fontname = "Arial",
        fontsize = "10"
    ];
}