Tinker with arrowheads on insnbox diagrams.

This commit is contained in:
John Winans 2020-02-23 10:41:35 -06:00
parent fa39de17f6
commit 108bc09205

View File

@ -265,9 +265,11 @@
\pgfmathsetmacro\posn{#1-#2+(#2-#3)/2} \pgfmathsetmacro\posn{#1-#2+(#2-#3)/2}
\pgfmathsetmacro\range{int(#2-#3+1)} \pgfmathsetmacro\range{int(#2-#3+1)}
\node at (\posn,-1.4) {\small\range}; % the field width
\node at (\posn,1.2) {\small#4}; % the field label \node at (\posn,1.2) {\small#4}; % the field label
% \node at (\posn,-1.4) {\small\range}; % the field width
\begin{scope}[shift={(0,-.7)}]\InsnBoxFieldWidthArrow{#2}{#3}\end{scope}
% % arrows showing the span of the bits... meh % % arrows showing the span of the bits... meh
% \draw[->] (\posn+.5,-1.4) -- (\rightpos+.2,-1.4); % \draw[->] (\posn+.5,-1.4) -- (\rightpos+.2,-1.4);
% \draw[->] (\posn-.5,-1.4) -- (\leftpos-.2,-1.4); % \draw[->] (\posn-.5,-1.4) -- (\leftpos-.2,-1.4);
@ -1059,31 +1061,46 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\BitBoxArrowInset{-.2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand\InsnBoxFieldWidthArrowVskip{.5}
\newcommand\InsnBoxFieldWidthArrowHskip{.05}
% #1 MSB position % #1 MSB position
% #2 LSB position % #2 LSB position
\newcommand\InsnBoxFieldWidthArrow[2]{ \newcommand\InsnBoxFieldWidthArrow[2]{
\pgfmathsetmacro\leftpos{int(31-#1)} % Calculate the left end position \pgfmathsetmacro\leftpos{int(31-#1)} % Calculate the left end position
\pgfmathsetmacro\wid{int(#1-#2+1)} % calculate the width \pgfmathsetmacro\wid{int(#1-#2+1)} % calculate the width
\begin{scope}[shift={(\leftpos,-.5)}] % Move to left end of arrow & below origin \begin{scope}[shift={(\leftpos,-\InsnBoxFieldWidthArrowVskip)}] % Move to left end of arrow & below origin
\pgfmathsetmacro\result{\wid*.5+.5} % the center position \pgfmathsetmacro\result{\wid*.5+.5} % the center position
\node at (\result,0) {\tiny\wid}; % size below the box \node at (\result,0) {\tiny\wid}; % draw the size number below the box
\ifthenelse{\wid > 9} \ifthenelse{\wid > 9} % make 1-9 narrower than 10-99
{ \pgfmathsetmacro\Inset{0.4} } { \pgfmathsetmacro\Inset{0.4} }
{ {
\ifthenelse{\wid > 1} \ifthenelse{\wid > 1} % make 1 narrower than 2-9
{ \pgfmathsetmacro\Inset{0.25} } { \pgfmathsetmacro\Inset{0.25} }
{ \pgfmathsetmacro\Inset{0.15} } { \pgfmathsetmacro\Inset{0.15} }
} }
\draw[->] (\result+\Inset,0) -- (\wid+.49,0); % arrow to the right % arrowsInsnBoxFieldWidthArrowHskip
\draw[->] (\result-\Inset,0) -- (.51,0); % arrow to the left \draw[->] (\result+\Inset,0) -- (\wid+.5-\InsnBoxFieldWidthArrowHskip,0); % arrow to the right
\draw[->] (\result-\Inset,0) -- (.5+\InsnBoxFieldWidthArrowHskip,0); % arrow to the left
\pgfmathsetmacro\x{.5}
\pgfmathsetmacro\y{\InsnBoxFieldWidthArrowVskip}
% vertical bars at the ends of the arrows
\draw[-] (\x,\y) -- (\x,-\y*.5);
\pgfmathsetmacro\x{(\wid+.5}
\draw[-] (\x,\y) -- (\x,-\y*.5);
\end{scope} \end{scope}
} }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\BitBoxArrowInset{-.2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\DrawInsnOpJTypeDecoding{ \newcommand\DrawInsnOpJTypeDecoding{
\BeginTikzPicture \BeginTikzPicture