Das sieht jetzt schon viel besser aus, ich habe auch Zustandsnamen hin zu gefügt - also
Z0 Z1 Z2 ...
Nur stehen die gerade alle bei
1
Das ändere ich, danach kommt der letzte Schliff mit den Verbindungen zu den Entscheidungsboxen.
Ich gebe dem Programm jetzt den letzten Schliff - zunächst werden Verbindungen gemacht an das Ende jeder Verzweigung - die Frage ist nur wohin? das ist ganz einfach. die eine führt ins Nichts oder an eine Verzweigung davor - die andere führt - vor die Verzweigung. Ich habe die Verzweigungen auf einem Stapel gespeichert, das ist kein Problem. Auf jeden Fall führt die letzte Verzweigung ins Nichts. Aber der letzte Zustand führt bei einer Verzweigung auf den Anfang der Entscheidung
Das sieht jetzt schon viel besser aus, ich habe auch Zustandsnamen hin zu gefügt - also
Z0 Z1 Z2 ...
Nur stehen die gerade alle bei
1
Das ändere ich, danach kommt der letzte Schliff mit den Verbindungen zu den Entscheidungsboxen.
Dies und viele weitere, das passt
Hier sind die erzeugten Code - in einer gewissen chronologie - am Anfang sind sie nicht richtig, am Ende schon.
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=4em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox, join] (z0) {verb" d <- 89 + 9 "}; node [ebox, yshift=-4em] (z1) { verb" 85 < 88 "}; node [zbox, join] (z2) {verb" c <- 112 \&\& 88 "}; node [zbox, join] (z3) {verb" b <- b + d "}; node [zbox, join] (z4) {verb" b <- b || 86 "}; node [zbox, join] (z5) {verb" a <- a "}; end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=4em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z0) {Zuweisungen in \$Z_0\$}; node [above=0mm of z0, text width=8em] {\$Z_0\$}; % Zustand 1, Box und Zustandsname node [zbox, join] (z1) {Zuweisungen in \$Z_0\$}; node [above=0mm of z1, text width=8em] {\$Z_1\$}; % Entscheidungsbox node [ebox, join] (e1) {Ent-\scheidungs- box}; % Zustand 2, Box und Zustandsname node [term, below=of e1.west, yshift=-4em] (z2) {bedingte Ausgangsbox}; node [above=0mm of z2, text width=8em]{}; % JA - Pfad aus der E-Box zu Z2 path (e1.west) to node [near start, xshift=-1em] {\$1\$} (z2); draw [->] (e1.west) -- (z2); % Zustand 3, Box und Zustandsname node [zbox, right =of z0] (z3) {Zuweisungen in \$Z_3\$}; node [above=0mm of z3, text width=8em] {\$Z_3\$}; % NEIN- Pfad aus der E-Box zu Z3 path (e1.east) to node [very near start] {\$0\$} (z3); node[coord, right = of e1, xshift=1em] (coord1) {}; %fill (coord1) circle (2pt); node[coord, above = of z3, yshift=2em] (coord2) {}; %fill (coord2) circle (2pt) {}; draw[->] (e1.east) -- (coord1) |- (coord2) -- (z3.north); end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z1) {verb" a <- 118 "}; node [zbox] (z2) {verb" a <- a "}; node [ebox] (z3) {verb" a != 90 "}; node [zbox, below=of z3.west, yshift=-4em] (z4) {verb" b <- c >> c "}; node [zbox, below=of z3.east, yshift=-4em] (z5) {verb" b <- 15 \&\& 40 "}; node [zbox] (z6) {verb" a <- b "}; node [zbox] (z7) {verb" b <- 34 "}; node [zbox] (z8) {verb" a <- a << 60 "}; node [ebox] (z9) {verb" b != d "}; node [zbox, below=of z9.west, yshift=-4em] (z10) {verb" d <- 3 \&\& b "}; node [ebox] (z11) {verb" 66 >= a "}; node [ebox, below=of z11.west, yshift=-4em] (z12) {verb" d != c "}; node [zbox, below=of z12.east, yshift=-4em] (z13) {verb" c <- 8 "}; node [zbox] (z14) {verb" b <- b || 46 "}; node [zbox] (z15) {verb" a <- a "}; node [ebox] (z16) {verb" 84 != a "}; node [zbox, below=of z16.east, yshift=-4em] (z17) {verb" d <- 18 "}; node [zbox, below=of z9.east, yshift=-4em] (z11) {verb" b <- 82 "}; end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z1) {verb" a <- 0 >> a "}; node [zbox] (z2) {verb" c <- a + 120 "}; node [zbox] (z3) {verb" b <- 110 "}; node [ebox] (z4) {verb" 17 >= 28 "}; node [zbox, below=of z4.west, yshift=-4em] (z5) {verb" c <- a "}; node [zbox] (z6) {verb" d <- 117 "}; node [zbox, below=of z4.east, yshift=-4em] (z7) {verb" a <- d - 126 "}; node [zbox] (z8) {verb" d <- c "}; node [zbox] (z9) {verb" d <- b - 113 "}; node [zbox] (z10) {verb" a <- b "}; node [ebox] (z11) {verb" 92 <= 124 "}; node [zbox, below=of z11.west, yshift=-4em] (z12) {verb" a <- 1 "}; node [zbox] (z13) {verb" d <- 104 "}; node [zbox, below=of z11.east, yshift=-4em] (z14) {verb" d <- 74 >> 59 "}; node [zbox] (z15) {verb" a <- d "}; node [zbox] (z16) {verb" d <- c + b "}; end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z1) {verb"R0 <- 10"}; draw [->] (z0) -- (z1); node [zbox] (z2) {verb"R1 <- R0 or R-1"}; draw [->] (z1) -- (z2); node [zbox] (z3) {verb"R2 <- R1 not R-1"}; draw [->] (z2) -- (z3); node [zbox] (z4) {verb"R3 <- R2 + 29"}; draw [->] (z3) -- (z4); node [zbox] (z5) {verb"R4 <- R3 or 24"}; draw [->] (z4) -- (z5); node [ebox] (z6) {verb"R5 <= 4"}; draw [->] (z5) -- (z6); node [zbox, below=of z6.west, yshift=-4em] (z7) {verb"R6 <- R5 not 7"}; draw [->] (z6.west) -- (z7); node [zbox] (z8) {verb"R7 <- R6 and R-1"}; draw [->] (z7) -- (z8); node [zbox, below=of z6.east, yshift=-4em] (z8) {verb"R8 <- R7 <| R4"}; draw [->] (z6.east) -- (z8); node [zbox] (z9) {verb"R9 <- R8 >> 20"}; draw [->] (z8) -- (z9); end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z1) {verb"R0 <- 22"}; node [ebox] (z2) {verb"R0 < 16"}; draw [->] (z1) -- (z2); node [zbox, below=of z2.east, yshift=-4em] (z3) {verb"R1 <- R0 |> R-1"}; draw [->] (z2.east) -- (z3); node [ebox] (z4) {verb"R2 <= 1"}; draw [->] (z3) -- (z4); node [ebox, below=of z4.west, yshift=-4em] (z5) {verb"R2 != 23"}; draw [->] (z4.west) -- (z5); node [ebox, below=of z5.west, yshift=-4em] (z6) {verb"R3 >= 2"}; draw [->] (z5.west) -- (z6); node [ebox, below=of z6.east, yshift=-4em] (z7) {verb"R4 < 3"}; draw [->] (z6.east) -- (z7); node [zbox, below=of z7.east, yshift=-4em] (z8) {verb"R5 <- R4 or R0"}; draw [->] (z7.east) -- (z8); node [zbox] (z9) {verb"R6 <- R5 --"}; draw [->] (z8) -- (z9); node [ebox] (z10) {verb"R6 != 18"}; draw [->] (z9) -- (z10); node [ebox, below=of z10.east, yshift=-4em] (z11) {verb"R7 > 6"}; draw [->] (z10.east) -- (z11); node [zbox, below=of z11.east, yshift=-4em] (z12) {verb"R8 <- R7 + R0"}; draw [->] (z11.east) -- (z12); end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z1) {verb"R0 <- 23"}; node [above=0mm of z1, text width=8em] {\$Z_1\$}; node [zbox] (z2) {verb"R1 <- R0 - 20"}; node [above=0mm of z2, text width=8em] {\$Z_1\$}; draw [->] (z1) -- (z2); node [zbox] (z3) {verb"R2 <- R1 - R0"}; node [above=0mm of z3, text width=8em] {\$Z_1\$}; draw [->] (z2) -- (z3); node [zbox] (z4) {verb"R3 <- R2 ++"}; node [above=0mm of z4, text width=8em] {\$Z_1\$}; draw [->] (z3) -- (z4); node [zbox] (z5) {verb"R4 <- R3 |> R0"}; node [above=0mm of z5, text width=8em] {\$Z_1\$}; draw [->] (z4) -- (z5); node [ebox] (z6) {verb"R4 != 6"}; node [above=0mm of z6, text width=8em] {\$Z_1\$}; draw [->] (z5) -- (z6); node [zbox, below=of z6.west, yshift=-4em] (z7) {verb"R5 <- R4 <| R0"}; node [above=0mm of z7, text width=8em] {\$Z_1\$}; draw [->] (z6.west) -- (z7); node [zbox] (z8) {verb"R6 <- R5 --"}; node [above=0mm of z8, text width=8em] {\$Z_1\$}; draw [->] (z7) -- (z8); node [zbox, below=of z6.east, yshift=-4em] (z8) {verb"R7 <- R6 not 28"}; node [above=0mm of z8, text width=8em] {\$Z_1\$}; draw [->] (z6.east) -- (z8); end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z1) {verb"R0 <- 20"}; node [above=0mm of z1, text width=8em] {\$Z_1\$}; node [ebox] (z2) {verb"R0 != 19"}; node [above=0mm of z2, text width=8em] {\$Z_1\$}; draw [->] (z1) -- (z2); node [zbox, below=of z2.west, yshift=-4em] (z3) {verb"R1 <- R0 - 20"}; node [above=0mm of z3, text width=8em] {\$Z_1\$}; draw [->] (z2.west) -- (z3); node [zbox] (z4) {verb"R2 <- R1 << 1"}; node [above=0mm of z4, text width=8em] {\$Z_1\$}; draw [->] (z3) -- (z4); node [zbox] (z5) {verb"R3 <- R2 ++"}; node [above=0mm of z5, text width=8em] {\$Z_1\$}; draw [->] (z4) -- (z5); node [ebox] (z6) {verb"R3 == 18"}; node [above=0mm of z6, text width=8em] {\$Z_1\$}; draw [->] (z5) -- (z6); node [zbox, below=of z6.east, yshift=-4em] (z7) {verb"R4 <- R3 >> 26"}; node [above=0mm of z7, text width=8em] {\$Z_1\$}; draw [->] (z6.east) -- (z7); node [zbox] (z8) {verb"R5 <- R4 xor R3"}; node [above=0mm of z8, text width=8em] {\$Z_1\$}; draw [->] (z7) -- (z8); node [zbox] (z9) {verb"R6 <- R5 - 28"}; node [above=0mm of z9, text width=8em] {\$Z_1\$}; draw [->] (z8) -- (z9); node [zbox] (z10) {verb"R7 <- R6 ++"}; node [above=0mm of z10, text width=8em] {\$Z_1\$}; draw [->] (z9) -- (z10); end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z1) {verb"R0 <- 30"}; node [above=0mm of z1, text width=8em] {\$Z_1\$}; node [zbox] (z2) {verb"R1 <- R0 and R0"}; node [above=0mm of z2, text width=8em] {\$Z_2\$}; draw [->] (z1) -- (z2); node [zbox] (z3) {verb"R2 <- R1 <| R0"}; node [above=0mm of z3, text width=8em] {\$Z_3\$}; draw [->] (z2) -- (z3); node [zbox] (z4) {verb"R3 <- R2 or 31"}; node [above=0mm of z4, text width=8em] {\$Z_4\$}; draw [->] (z3) -- (z4); node [zbox] (z5) {verb"R4 <- R3 and 27"}; node [above=0mm of z5, text width=8em] {\$Z_5\$}; draw [->] (z4) -- (z5); node [zbox] (z6) {verb"R5 <- R4 << R1"}; node [above=0mm of z6, text width=8em] {\$Z_6\$}; draw [->] (z5) -- (z6); node [zbox] (z7) {verb"R6 <- R5 --"}; node [above=0mm of z7, text width=8em] {\$Z_7\$}; draw [->] (z6) -- (z7); node [zbox] (z8) {verb"R7 <- R6 + R0"}; node [above=0mm of z8, text width=8em] {\$Z_8\$}; draw [->] (z7) -- (z8); node [zbox] (z9) {verb"R8 <- R7 - 1"}; node [above=0mm of z9, text width=8em] {\$Z_9\$}; draw [->] (z8) -- (z9); node [ebox] (z10) {verb"R8 < 20"}; node [above=0mm of z10, text width=8em] {\$Z_10\$}; draw [->] (z9) -- (z10); node [zbox, below=of z10.east, yshift=-4em] (z11) {verb"R9 <- R8 <| 30"}; node [above=0mm of z11, text width=8em] {\$Z_11\$}; draw [->] (z10.east) -- (z11); node [zbox] (z12) {verb"R10 <- R9 and 16"}; node [above=0mm of z12, text width=8em] {\$Z_12\$}; draw [->] (z11) -- (z12); end{tikzpicture}
begin{tikzpicture}[% >=triangle 60, % Aussehen der Pfeile start chain=going below, % Richtung von oben nach unten node distance=6mm and 60mm, % Abst"ande der Boxen every join/.style={norm}, ] tikzset{% Boxen und Koordinaten base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} % Zustand 0, Box und Zustandsname node [zbox] (z1) {verb"R0 <- 8"}; node [above=0mm of z1, text width=8em] {\$Z_{1}\$}; node [ebox] (z2) {verb"R0 < 15"}; node [above=0mm of z2, text width=8em] {\$Z_{2}\$}; draw [->] (z1) -- (z2); node [zbox, below=of z2.west, yshift=-4em] (z3) {verb"R1 <- R0 or 19"}; node [above=0mm of z3, text width=8em] {\$Z_{3}\$}; draw [->] (z2.west) -- (z3); node [zbox] (z4) {verb"R2 <- R1 >> 13"}; node [above=0mm of z4, text width=8em] {\$Z_{4}\$}; draw [->] (z3) -- (z4); node [zbox] (z5) {verb"R3 <- R2 ++"}; node [above=0mm of z5, text width=8em] {\$Z_{5}\$}; draw [->] (z4) -- (z5); node [zbox] (z6) {verb"R4 <- R3 --"}; node [above=0mm of z6, text width=8em] {\$Z_{6}\$}; draw [->] (z5) -- (z6); node [zbox] (z7) {verb"R5 <- R4 ++"}; node [above=0mm of z7, text width=8em] {\$Z_{7}\$}; draw [->] (z6) -- (z7); node [zbox] (z8) {verb"R6 <- R5 << R4"}; node [above=0mm of z8, text width=8em] {\$Z_{8}\$}; draw [->] (z7) -- (z8); node [zbox] (z9) {verb"R7 <- R6 not 19"}; node [above=0mm of z9, text width=8em] {\$Z_{9}\$}; draw [->] (z8) -- (z9); node [ebox] (z10) {verb"R7 < 13"}; node [above=0mm of z10, text width=8em] {\$Z_{10}\$}; draw [->] (z9) -- (z10); node [zbox, below=of z10.east, yshift=-4em] (z11) {verb"R8 <- R7 ++"}; node [above=0mm of z11, text width=8em] {\$Z_{11}\$}; draw [->] (z10.east) -- (z11); node [zbox] (z12) {verb"R9 <- R8 <| R4"}; node [above=0mm of z12, text width=8em] {\$Z_{12}\$}; draw [->] (z11) -- (z12); end{tikzpicture}
So, ich schreibe das Programm jetzt fertig. Zunächst mache ich eine sinnvollausgabe. Es wird nicht einfach - eine Datei erzeugt, die eingebunden wird, sondern es wird eine komplette
TeX-Datei erzeugt
Diese wird nicht als Datei gespeichert, sondern als Ausgabe und lässt sich umlenken. Die Überschrift kommt weg.
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #define NO 0 #define WEST 1 #define EAST 2 #define MAX_NODES 64 #define STACKS_MAX 4 char *op_names [] = {"==", "!=", ">", ">=", "<", "<=", "+", "++", "-", "--", "<<", ">>", "<|", "|>", "and", "not", "or", "xor", "+", "++", "-", "--", "<<", ">>", "<|", "|>", "and", "not", "or", "xor", "<-" }; #define OP_CMP_EQ_REG_CONST 0 #define OP_CMP_NE_REG_CONST 1 #define OP_CMP_GR_REG_CONST 2 #define OP_CMP_GE_REG_CONST 3 #define OP_CMP_LT_REG_CONST 4 #define OP_CMP_LE_REG_CONST 5 #define OP_ADD_REG_REG_CONST 6 #define OP_INC_REG_REG_CONST 7 #define OP_SUB_REG_REG_CONST 8 #define OP_DEC_REG_REG_CONST 9 #define OP_SLL_REG_REG_CONST 10 #define OP_SLR_REG_REG_CONST 11 #define OP_RL_REG_REG_CONST 12 #define OP_RR_REG_REG_CONST 13 #define OP_AND_REG_REG_CONST 14 #define OP_NOT_REG_REG_CONST 15 #define OP_OR_REG_REG_CONST 16 #define OP_EXOR_REG_REG_CONST 17 #define OP_ADD_REG_REG_REG 18 #define OP_INC_REG_REG_REG 19 #define OP_SUB_REG_REG_REG 20 #define OP_DEC_REG_REG_REG 21 #define OP_SLL_REG_REG_REG 22 #define OP_SLR_REG_REG_REG 23 #define OP_RL_REG_REG_REG 24 #define OP_RR_REG_REG_REG 25 #define OP_AND_REG_REG_REG 26 #define OP_NOT_REG_REG_REG 27 #define OP_OR_REG_REG_REG 28 #define OP_EXOR_REG_REG_REG 29 #define OP_ASSIGNMENT_REG_CONST 30 #define NA -1 #define EMPTY -2 #define STACK_UNDERFLOW -3 #define STACK_OPCODE 0 #define STACK_OP1 1 #define STACK_OP2 2 #define STACK_OP3 3 #define MAX_COND 3 #define CONST_MAX 32 int stack [STACKS_MAX][MAX_NODES]; int stack2 [MAX_NODES]; int stack_ptr [STACKS_MAX]; int queue_ptr [STACKS_MAX]; int stack_ptr2 = 0; void init_stack (void) { int i; for (i = 0; i < STACKS_MAX; i++) { stack_ptr [i] = 0; } return; } void queue_init (void) { int i; for (i = 0; i < STACKS_MAX; i++) { queue_ptr [i] = 0; } return; } void push (int stck, int v) { if (stack_ptr[stck] < (MAX_NODES-1)) { stack [stck][stack_ptr [stck]] = v; stack_ptr [stck]++; } return; } int pop (int stck) { if (stack_ptr [stck] > 0) { stack_ptr [stck]--; return stack [stck][stack_ptr [stck]]; } else return STACK_UNDERFLOW; } int getstckptr (int stck) { return stack_ptr [stck]; } int get (int stck) { if (queue_ptr [stck] < stack_ptr [stck]) { return stack [stck][queue_ptr [stck]++]; } else return EMPTY; } void unget (int stck) { if (queue_ptr [stck] > 0) queue_ptr [stck]--; } void push2 (int v) { if (stack_ptr2 < (MAX_NODES-1)) { stack2 [stack_ptr2] = v; stack_ptr2++; } } int pop2 (void) { if (stack_ptr2 > 0) { stack_ptr2--; return stack2 [stack_ptr2]; } } int regmax = 0; /* * reg ::= op reg reg reg | op reg reg const | op const * cond ::= op_cmp reg const addr1 addr2 */ void init () { int i = 0; int cond_count = MAX_COND; int cond_least = 0; int op; int imax = (rand () % 6) + 5; int lastreg; int r; push (STACK_OPCODE, OP_ASSIGNMENT_REG_CONST); // Assignment at begin push (STACK_OP1, 0); // Register R0 () push (STACK_OP2, rand () % CONST_MAX); // Const push (STACK_OP3, NA); // Operand 3, assignment, not given for (i = 1; i < imax; i++) { op = rand () % (OP_EXOR_REG_REG_REG+1); if ((op <= OP_CMP_LE_REG_CONST) \&\& (cond_least == 0)) { if (cond_count > 0) { cond_count--; lastreg = pop (STACK_OP1); push (STACK_OP1, lastreg); push (STACK_OPCODE, op); push (STACK_OP1, lastreg); push (STACK_OP2, rand () % CONST_MAX); push (STACK_OP3, NA ); cond_least = 2; if ((i + cond_least) > imax) { imax += cond_least; } push2 (i); } else { i--; } } else if (op > OP_CMP_LE_REG_CONST){ if (cond_least != 0) cond_least--; lastreg = pop (STACK_OP1); push (STACK_OP1, lastreg); push (STACK_OPCODE, op); push (STACK_OP1, lastreg+1); push (STACK_OP2, lastreg); if ((op >= OP_ADD_REG_REG_REG) \&\& (op <= OP_EXOR_REG_REG_REG)) { r = (rand () % (lastreg+1))-1; if (r < 0) r = 0; push (STACK_OP3, r); } else push (STACK_OP3, rand () % CONST_MAX); } else i--; } push (STACK_OPCODE, EMPTY); push (STACK_OP1, EMPTY); push (STACK_OP2, EMPTY); push (STACK_OP3, EMPTY); } void test_output (void) { int p, o1, o2, o3; while ((p = get (STACK_OPCODE)) != EMPTY) { if ((p >= OP_CMP_EQ_REG_CONST) \&\& (p <= OP_CMP_LE_REG_CONST)) { printf ("R%i %s %in", get (STACK_OP1), op_names [p], get(STACK_OP2)); get (STACK_OP3); } else if (p == OP_ASSIGNMENT_REG_CONST) { printf ("R%i %s %in", get (STACK_OP1), op_names [p], get(STACK_OP2)); get (STACK_OP3); } else { if ((p == OP_INC_REG_REG_CONST) || (p == OP_INC_REG_REG_REG) || (p == OP_DEC_REG_REG_CONST) || (p == OP_DEC_REG_REG_REG)) { printf ("R%i %s R%i %sn", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p]); get (STACK_OP3); } else if ((p >= OP_ADD_REG_REG_CONST) \&\& (p <= OP_EXOR_REG_REG_CONST)) printf ("R%i %s R%i %s %in", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p], get (STACK_OP3)); else printf ("R%i %s R%i %s R%in", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p], get (STACK_OP3)); } } } int expr (int z, int zs, int dir) { int p = get (STACK_OPCODE); if (dir == NO) { printf BITTE IM PDF NACHGUCKEN } else if (dir == WEST) { printf BITTE IM PDF NACHGUCKEN } else if (dir == EAST) { printf BITTE IM PDF NACHGUCKEN } if (p == OP_ASSIGNMENT_REG_CONST) { printf ("R%i %s %i", get (STACK_OP1), op_names [p], get(STACK_OP2)); get (STACK_OP3); } else if ((p == OP_INC_REG_REG_CONST) || (p == OP_INC_REG_REG_REG) || (p == OP_DEC_REG_REG_CONST) || (p == OP_DEC_REG_REG_REG)) { printf ("R%i %s R%i %s", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p]); get (STACK_OP3); } else if ((p >= OP_ADD_REG_REG_CONST) \&\& (p <= OP_EXOR_REG_REG_CONST)) printf ("R%i %s R%i %s %i", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p], get (STACK_OP3)); else { printf ("R%i %s R%i %s R%i", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p], get (STACK_OP3)); } printf (""};n"); printf ("\node [above=0mm of z%i, text width=8em] {\$Z_{%i}\$};n", z, z); if (z != 1) { if (dir == NO) { printf ("\draw [->] (z%i) -- (z%i);nn", zs, z); } else if (dir == WEST) { printf ("\draw [->] (z%i.west) -- (z%i);nn", zs, z); } else if (dir == EAST) { printf ("\draw [->] (z%i.east) -- (z%i);nn", zs, z); } } return z; } int cond (int z, int zs, int dir) { int p = get (STACK_OPCODE); if (dir == NO) { printf BITTE IM PDF NACHGUCKEN } else if (dir == WEST) { printf BITTE IM PDF NACHGUCKEN } else if (dir == EAST) { printf BITTE IM PDF NACHGUCKEN } printf ("R%i %s %i", get (STACK_OP1), op_names [p], get(STACK_OP2)); get (STACK_OP3); printf (""};n"); printf ("\node [above=0mm of z%i, text width=8em] {\$Z_{%i}\$};n", z, z); if (z != 1) { if (dir == NO) { printf ("\draw [->] (z%i) -- (z%i);nn", zs, z); } else if (dir == WEST) { printf ("\draw [->] (z%i.west) -- (z%i);nn", zs, z); } else if (dir == EAST) { printf ("\draw [->] (z%i.east) -- (z%i);nn", zs, z); } } return z; } int as (int z, int zs, int dir, int steps) { int ztmp; int r, rtmp; int stepsr; int stepss; if (steps > 0) { r = get (STACK_OPCODE); if ((r >= OP_CMP_EQ_REG_CONST) \&\& (r <= OP_CMP_LE_REG_CONST)){ unget (STACK_OPCODE); z = ztmp = cond (z+1, z, dir); stepsr = (rand () % steps)-1; stepss = steps - stepsr; z = as (z, z, WEST, stepsr); z = as (z, ztmp, EAST, stepss); } else if (r != EMPTY) { unget (STACK_OPCODE); z = expr (z+1, zs, dir); as (z, z, NO, steps-1); } else return STACK_UNDERFLOW; } return z; } int main (void) { time_t t; int j; srand (t = time(NULL)); init_stack (); queue_init (); init (); //test_output (); printf("\documentclass{article}n"); printf("\usepackage[utf8]{inputenc}n"); printf("\usepackage{pgf, tikz}n"); printf("\usetikzlibrary{shapes, chains, calc, arrows, positioning}nn"); printf("\begin{document}nn"); queue_init (); printf("\begin{center}n"); printf("\begin{tikzpicture}[%n"); printf("t>=triangle 60, n"); printf("tstart chain=going below, n"); printf("tnode distance=6mm and 60mm, n"); printf("tevery join/.style={norm},n"); printf("]n"); printf("\tikzset{n"); printf("base/.style={draw, on chain, on grid, align=center, minimum height=4ex},n"); printf("zbox/.style={base, rectangle, text width=8em},n"); printf("ebox/.style={base, diamond, aspect=1.5, text width=10em},n"); printf("term/.style={zbox, rounded corners},n"); printf("norm/.style={->, draw},n"); printf("coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}}nn"); as (0, 0, NO, getstckptr (STACK_OPCODE)); printf ("\end{tikzpicture}nn"); printf ("\end{center}nn"); printf("\end{document}n"); return 0; }
documentclass{article} usepackage[utf8]{inputenc} usepackage{pgf, tikz} usetikzlibrary{shapes, chains, calc, arrows, positioning} begin{document} begin{center} begin{tikzpicture}[% >=triangle 60, start chain=going below, node distance=6mm and 60mm, every join/.style={norm}, ] tikzset{ base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} node [zbox] (z0) {verb"R0 <- 26 >> d "}; node [ebox] (z1) {verb"R0 > 9"}; node [above=0mm of z1, text width=8em] {\$Z_{1}\$}; node [zbox, below=of z1.west, yshift=-4em] (z2) {verb"R1 <- R0 + -1"}; node [above=0mm of z2, text width=8em] {\$Z_{2}\$}; draw [->] (z1.west) -- (z2); node [zbox] (z3) {verb"R2 <- R1 - R14"}; node [above=0mm of z3, text width=8em] {\$Z_{3}\$}; draw [->] (z2) -- (z3); node [zbox] (z4) {verb"R3 <- R2 not 0"}; node [above=0mm of z4, text width=8em] {\$Z_{4}\$}; draw [->] (z3) -- (z4); node [ebox] (z5) {verb"R3 > 0"}; node [above=0mm of z5, text width=8em] {\$Z_{5}\$}; draw [->] (z4) -- (z5); node [zbox, below=of z5.east, yshift=-4em] (z6) {verb"R4 <- R3 + R-1"}; node [above=0mm of z6, text width=8em] {\$Z_{6}\$}; draw [->] (z5.east) -- (z6); node [zbox] (z7) {verb"R5 <- R4 <| 2"}; node [above=0mm of z7, text width=8em] {\$Z_{7}\$}; draw [->] (z6) -- (z7); node [zbox] (z8) {verb"R6 <- R5 - R12"}; node [above=0mm of z8, text width=8em] {\$Z_{8}\$}; draw [->] (z7) -- (z8); node [zbox, below=of z1.east, yshift=-4em] (z3) {verb"R7 <- R6 << 2"}; node [above=0mm of z3, text width=8em] {\$Z_{3}\$}; draw [->] (z1.east) -- (z3); end{tikzpicture} end{center} end{document}
documentclass{article} usepackage[utf8]{inputenc} usepackage{pgf, tikz} usetikzlibrary{shapes, chains, calc, arrows, positioning} begin{document} begin{center} begin{tikzpicture}[% >=triangle 60, start chain=going below, node distance=6mm and 60mm, every join/.style={norm}, ] tikzset{ base/.style={draw, on chain, on grid, align=center, minimum height=4ex}, zbox/.style={base, rectangle, text width=8em}, ebox/.style={base, diamond, aspect=1.5, text width=10em}, term/.style={zbox, rounded corners}, norm/.style={->, draw}, coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}} node [zbox] (z1) {verb"R0 <- 4"}; node [above=0mm of z1, text width=8em] {\$Z_{1}\$}; node [zbox] (z2) {verb"R1 <- R0 --"}; node [above=0mm of z2, text width=8em] {\$Z_{2}\$}; draw [->] (z1) -- (z2); node [zbox] (z3) {verb"R2 <- R1 --"}; node [above=0mm of z3, text width=8em] {\$Z_{3}\$}; draw [->] (z2) -- (z3); node [zbox] (z4) {verb"R3 <- R2 - 25"}; node [above=0mm of z4, text width=8em] {\$Z_{4}\$}; draw [->] (z3) -- (z4); node [zbox] (z5) {verb"R4 <- R3 not 21"}; node [above=0mm of z5, text width=8em] {\$Z_{5}\$}; draw [->] (z4) -- (z5); node [zbox] (z6) {verb"R5 <- R4 --"}; node [above=0mm of z6, text width=8em] {\$Z_{6}\$}; draw [->] (z5) -- (z6); node [zbox] (z7) {verb"R6 <- R5 <| 27"}; node [above=0mm of z7, text width=8em] {\$Z_{7}\$}; draw [->] (z6) -- (z7); node [ebox] (z8) {verb"R6 > 1"}; node [above=0mm of z8, text width=8em] {\$Z_{8}\$}; draw [->] (z7) -- (z8); node [zbox, below=of z8.east, yshift=-4em] (z9) {verb"R7 <- R6 not 6"}; node [above=0mm of z9, text width=8em] {\$Z_{9}\$}; draw [->] (z8.east) -- (z9); node [zbox] (z10) {verb"R8 <- R7 << 19"}; node [above=0mm of z10, text width=8em] {\$Z_{10}\$}; draw [->] (z9) -- (z10); end{tikzpicture} end{center} end{document}
Hier noch mal der C-Code
https://www.ituenix.de/nextcloud/data/dave/files/Documents/david4/2024-01-28/asmparser14.c">https://www.ituenix.de/nextcloud/data/dave/files/Documents/david4/2024-01-28/asmparser14.c</URL> \begin{verbatim} #include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #define NO 0 #define WEST 1 #define EAST 2 #define MAX_NODES 64 #define STACKS_MAX 4 char *op_names [] = {"==", "!=", ">", ">=", "<", "<=", "+", "++", "-", "--", "<<", ">>", "<|", "|>", "and", "not", "or", "xor", "+", "++", "-", "--", "<<", ">>", "<|", "|>", "and", "not", "or", "xor", "<-" }; #define OP_CMP_EQ_REG_CONST 0 #define OP_CMP_NE_REG_CONST 1 #define OP_CMP_GR_REG_CONST 2 #define OP_CMP_GE_REG_CONST 3 #define OP_CMP_LT_REG_CONST 4 #define OP_CMP_LE_REG_CONST 5 #define OP_ADD_REG_REG_CONST 6 #define OP_INC_REG_REG_CONST 7 #define OP_SUB_REG_REG_CONST 8 #define OP_DEC_REG_REG_CONST 9 #define OP_SLL_REG_REG_CONST 10 #define OP_SLR_REG_REG_CONST 11 #define OP_RL_REG_REG_CONST 12 #define OP_RR_REG_REG_CONST 13 #define OP_AND_REG_REG_CONST 14 #define OP_NOT_REG_REG_CONST 15 #define OP_OR_REG_REG_CONST 16 #define OP_EXOR_REG_REG_CONST 17 #define OP_ADD_REG_REG_REG 18 #define OP_INC_REG_REG_REG 19 #define OP_SUB_REG_REG_REG 20 #define OP_DEC_REG_REG_REG 21 #define OP_SLL_REG_REG_REG 22 #define OP_SLR_REG_REG_REG 23 #define OP_RL_REG_REG_REG 24 #define OP_RR_REG_REG_REG 25 #define OP_AND_REG_REG_REG 26 #define OP_NOT_REG_REG_REG 27 #define OP_OR_REG_REG_REG 28 #define OP_EXOR_REG_REG_REG 29 #define OP_ASSIGNMENT_REG_CONST 30 #define NA -1 #define EMPTY -2 #define STACK_UNDERFLOW -3 #define STACK_OPCODE 0 #define STACK_OP1 1 #define STACK_OP2 2 #define STACK_OP3 3 #define MAX_COND 3 #define CONST_MAX 32 int stack [STACKS_MAX][MAX_NODES]; int stack2 [MAX_NODES]; int stack_ptr [STACKS_MAX]; int queue_ptr [STACKS_MAX]; int stack_ptr2 = 0; void init_stack (void) { int i; for (i = 0; i < STACKS_MAX; i++) { stack_ptr [i] = 0; } return; } void queue_init (void) { int i; for (i = 0; i < STACKS_MAX; i++) { queue_ptr [i] = 0; } return; } void push (int stck, int v) { if (stack_ptr[stck] < (MAX_NODES-1)) { stack [stck][stack_ptr [stck]] = v; stack_ptr [stck]++; } return; } int pop (int stck) { if (stack_ptr [stck] > 0) { stack_ptr [stck]--; return stack [stck][stack_ptr [stck]]; } else return STACK_UNDERFLOW; } int getstckptr (int stck) { return stack_ptr [stck]; } int get (int stck) { if (queue_ptr [stck] < stack_ptr [stck]) { return stack [stck][queue_ptr [stck]++]; } else return EMPTY; } void unget (int stck) { if (queue_ptr [stck] > 0) queue_ptr [stck]--; } void push2 (int v) { if (stack_ptr2 < (MAX_NODES-1)) { stack2 [stack_ptr2] = v; stack_ptr2++; } } int pop2 (void) { if (stack_ptr2 > 0) { stack_ptr2--; return stack2 [stack_ptr2]; } } int regmax = 0; /* * reg ::= op reg reg reg | op reg reg const | op const * cond ::= op_cmp reg const addr1 addr2 */ void init () { int i = 0; int cond_count = MAX_COND; int cond_least = 0; int op; int imax = (rand () % 6) + 5; int lastreg; int r; push (STACK_OPCODE, OP_ASSIGNMENT_REG_CONST); // Assignment at begin push (STACK_OP1, 0); // Register R0 () push (STACK_OP2, rand () % CONST_MAX); // Const push (STACK_OP3, NA); // Operand 3, assignment, not given for (i = 1; i < imax; i++) { op = rand () % (OP_EXOR_REG_REG_REG+1); if ((op <= OP_CMP_LE_REG_CONST) \&\& (cond_least == 0)) { if (cond_count > 0) { cond_count--; lastreg = pop (STACK_OP1); push (STACK_OP1, lastreg); push (STACK_OPCODE, op); push (STACK_OP1, lastreg); push (STACK_OP2, rand () % CONST_MAX); push (STACK_OP3, NA ); cond_least = 2; if ((i + cond_least) > imax) { imax += cond_least; } push2 (i); } else { i--; } } else if (op > OP_CMP_LE_REG_CONST){ if (cond_least != 0) cond_least--; lastreg = pop (STACK_OP1); push (STACK_OP1, lastreg); push (STACK_OPCODE, op); push (STACK_OP1, lastreg+1); push (STACK_OP2, lastreg); if ((op >= OP_ADD_REG_REG_REG) \&\& (op <= OP_EXOR_REG_REG_REG)) { r = (rand () % (lastreg+1))-1; if (r < 0) r = 0; push (STACK_OP3, r); } else push (STACK_OP3, rand () % CONST_MAX); } else i--; } push (STACK_OPCODE, EMPTY); push (STACK_OP1, EMPTY); push (STACK_OP2, EMPTY); push (STACK_OP3, EMPTY); } void test_output (void) { int p, o1, o2, o3; while ((p = get (STACK_OPCODE)) != EMPTY) { if ((p >= OP_CMP_EQ_REG_CONST) \&\& (p <= OP_CMP_LE_REG_CONST)) { printf ("R%i %s %in", get (STACK_OP1), op_names [p], get(STACK_OP2)); get (STACK_OP3); } else if (p == OP_ASSIGNMENT_REG_CONST) { printf ("R%i %s %in", get (STACK_OP1), op_names [p], get(STACK_OP2)); get (STACK_OP3); } else { if ((p == OP_INC_REG_REG_CONST) || (p == OP_INC_REG_REG_REG) || (p == OP_DEC_REG_REG_CONST) || (p == OP_DEC_REG_REG_REG)) { printf ("R%i %s R%i %sn", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p]); get (STACK_OP3); } else if ((p >= OP_ADD_REG_REG_CONST) \&\& (p <= OP_EXOR_REG_REG_CONST)) printf ("R%i %s R%i %s %in", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p], get (STACK_OP3)); else printf ("R%i %s R%i %s R%in", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p], get (STACK_OP3)); } } } int expr (int z, int zs, int dir) { int p = get (STACK_OPCODE); if (dir == NO) { printf BITTE IM PDF NACHGUCKEN } else if (dir == WEST) { printf BITTE IM PDF NACHGUCKEN } else if (dir == EAST) { printf BITTE IM PDF NACHGUCKEN } if (p == OP_ASSIGNMENT_REG_CONST) { printf ("R%i %s %i", get (STACK_OP1), op_names [p], get(STACK_OP2)); get (STACK_OP3); } else if ((p == OP_INC_REG_REG_CONST) || (p == OP_INC_REG_REG_REG) || (p == OP_DEC_REG_REG_CONST) || (p == OP_DEC_REG_REG_REG)) { printf ("R%i %s R%i %s", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p]); get (STACK_OP3); } else if ((p >= OP_ADD_REG_REG_CONST) \&\& (p <= OP_EXOR_REG_REG_CONST)) printf ("R%i %s R%i %s %i", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p], get (STACK_OP3)); else { printf ("R%i %s R%i %s R%i", get (STACK_OP1), op_names [OP_ASSIGNMENT_REG_CONST], get (STACK_OP2), op_names [p], get (STACK_OP3)); } printf (""};n"); printf ("\node [above=0mm of z%i, text width=8em] {\$Z_{%i}\$};n", z, z); if (z != 1) { if (dir == NO) { printf ("\draw [->] (z%i) -- (z%i);nn", zs, z); } else if (dir == WEST) { printf ("\draw [->] (z%i.west) -- (z%i);nn", zs, z); } else if (dir == EAST) { printf ("\draw [->] (z%i.east) -- (z%i);nn", zs, z); } } return z; } int cond (int z, int zs, int dir) { int p = get (STACK_OPCODE); if (dir == NO) { printf BITTE IM PDF NACHGUCKEN } else if (dir == WEST) { printf BITTE IM PDF NACHGUCKEN } else if (dir == EAST) { printf BITTE IM PDF NACHGUCKEN } printf ("R%i %s %i", get (STACK_OP1), op_names [p], get(STACK_OP2)); get (STACK_OP3); printf (""};n"); printf ("\node [above=0mm of z%i, text width=8em] {\$Z_{%i}\$};n", z, z); if (z != 1) { if (dir == NO) { printf ("\draw [->] (z%i) -- (z%i);nn", zs, z); } else if (dir == WEST) { printf ("\draw [->] (z%i.west) -- (z%i);nn", zs, z); } else if (dir == EAST) { printf ("\draw [->] (z%i.east) -- (z%i);nn", zs, z); } } return z; } int as (int z, int zs, int dir, int steps) { int ztmp; int r, rtmp; int stepsr; int stepss; if (steps > 0) { r = get (STACK_OPCODE); if ((r >= OP_CMP_EQ_REG_CONST) \&\& (r <= OP_CMP_LE_REG_CONST)){ unget (STACK_OPCODE); z = ztmp = cond (z+1, z, dir); stepsr = (rand () % steps)-1; stepss = steps - stepsr; z = as (z, z, WEST, stepsr); z = as (z, ztmp, EAST, stepss); } else if (r != EMPTY) { unget (STACK_OPCODE); z = expr (z+1, zs, dir); as (z, z, NO, steps-1); } else return STACK_UNDERFLOW; } return z; } int main (void) { time_t t; int j; srand (t = time(NULL)); init_stack (); queue_init (); init (); //test_output (); printf("\documentclass{article}n"); printf("\usepackage[utf8]{inputenc}n"); printf("\usepackage{pgf, tikz}n"); printf("\usetikzlibrary{shapes, chains, calc, arrows, positioning}nn"); printf("\begin{document}nn"); queue_init (); printf("\begin{center}n"); printf("\begin{tikzpicture}[%n"); printf("t>=triangle 60, n"); printf("tstart chain=going below, n"); printf("tnode distance=6mm and 60mm, n"); printf("tevery join/.style={norm},n"); printf("]n"); printf("\tikzset{n"); printf("base/.style={draw, on chain, on grid, align=center, minimum height=4ex},n"); printf("zbox/.style={base, rectangle, text width=8em},n"); printf("ebox/.style={base, diamond, aspect=1.5, text width=10em},n"); printf("term/.style={zbox, rounded corners},n"); printf("norm/.style={->, draw},n"); printf("coord/.style={coordinate, on chain, on grid, node distance=6mm and 25mm}}nn"); as (0, 0, NO, getstckptr (STACK_OPCODE)); printf ("\end{tikzpicture}nn"); printf ("\end{center}nn"); printf("\end{document}n"); return 0; }