# How to set tikz node size in terms of other coordinates?

I need a way to get LaTeX to see that I'm trying to draw a node with it's borders set at coordinates. If I could tell it the diagonal angle to create a box around, or anything else to draw the shape on, I would. I have the following:

\node[draw,minimum width=1cm,below=.5cm of bytes] (byte1) {$6A$} ; %valid
\node[draw,minimum width=1cm,below=0pt of byte1] (byte2) {$00$} ; %invalid
\draw let \p1 = (byte1.north west),
\p2 = (byte2.south west) in
(\p1) -- (\p2) node [name=insn1,draw,left=of byte1] {push 0x0;};


What I actually want, however, is for insn1 to be sized enough to contain each of byte1 and byte2, but shifted to the left of each of them. What I have expressed, just makes insn1 the size enough to contain the text push 0x0;, but to the left ob byte1. What I thought I got by using the (\p1) -- (\p2) part, was an edge around which to place the box.

\draw (\p1) -- (\p2) just draws a line from \p1 to \p2. Appending node [...] {...} to the end of such a path just places the node at the last coordinate in the path (here \p2). The path up to that point has no bearing on the size of the node itself. (In your case though the left=byte1 takes precedence, and is what determines the position.)

For example with \draw (0,0) -- (2,3) node{foo}; you get a line between the two coordinates, and the foo node is placed at (2,3).

But what you can do is to use \p1 and \p2 to calculate the total height of byte1 and byte2, and set the minimum height of the node to that value. Or you can use the fit library and its fit option. Both are shown below.

(Unrelated: If you don't want the double line width between byte1 and byte2, set below=-\pgflinewidth of byte1 in the settings for byte2. You currently have below=0pt of byte1.)

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,fit}
\begin{document}

\begin{tikzpicture}
\coordinate (bytes);
\node[draw,minimum width=1cm,below=.5cm of bytes] (byte1) {$6A$} ; %valid
\node[draw,minimum width=1cm,below=0pt of byte1] (byte2) {$00$} ; %invalid

\node [name=insn1,
draw,
fit=(byte1)(byte2), %make the node so large that these two fit inside
inner sep=0pt, % and with zero padding, the fit is snug
left=of byte1.north west, % this and the next line to align the tops
anchor=north,
text height=2.2ex % for better vertical alignment of the text inside the node
] {push 0x0;};

\path let
\p1 = (byte1.north west),
\p2 = (byte2.south west),
\n1 = {\y1-\y2} %\yN is y-coordinate of \pN
in
node [name=insn1,
draw,
minimum height=\n1, % set minimum height to the calculated \n1
right=of byte1.north east,
anchor=north
] {push 0x0;};
\end{tikzpicture}

\end{document}


as supplement to nice Torbjørn T. answer, without use of fit library:

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{calc, positioning}

\begin{document}

\begin{tikzpicture}[
node distance = 0mm and 10mm,
N/.style = {draw, minimum width=10mm, align=center, outer sep=0mm}
]
\node (byte1) [N] {$6A$}; %valid
\node (byte2) [N, below=0pt of byte1] {$00$}; %invalid
%
\path   let \p1 = (byte1.north),
\p2 = (byte2.south),
\n1 = {\y1-\y2} in
node (insn1) [N, minimum height=\n1, % set minimum height by \n1
left=of byte1.south west,
] {push\\ 0x0}
node (insn2) [N, minimum height=\n1, % set minimum height by \n1
right=of byte1.south east,
] {push 0x0};
\end{tikzpicture}

\end{document}