I'm not really a latex newbie nor an expert.
My question is about the bytefield package and how to define a new command.
I would like to represent graphically a fictive 32 bits instruction set. Of course there are different formats (register-register, register-immediate...). The commands are made of:
-a 5 bits wide opcode
-one bit to indicate the type of instruction
-data which can be 3 register ID (each 5 bits wide) or 2 register IDs and 16 bits immediate data (according to the previous bit)
I know how to draw such things with the bytefield package which is something like:
Code: Select all
\begin{bytefield}{32}
\bitheader[b]{31,27,26,25,21,20,16,15,0} \\
\bitbox{5}{$10000$} & \bitbox{1}{$1$} & \bitbox{5}{$00001$} & \bitbox{5}{$11111$} & \bitbox{5}{$11111$} & \bitbox{11}{$000000000000000$}
\end{bytefield}
\regreg{opcode}{ID1}{ID2}{ID3} for register-register instructions
I tried the following:
Code: Select all
\newcommand{\regreg}[4]{
\begin{bytefield}{32}
\bitheader[b]{31,27,26,21,20,16,15,11,10,0} \\
\bitbox{5}{#1} & \bitbox{1}{$0$} & \bitbox{5}{#2} & \bitbox{5}{#3} & \bitbox{5}{#4} & \bitbox{11}{$00000000000$}
\end{bytefield}
}
"Extra alignment tab has been changed to \cr. ".
The error seems to come from \bitbox{1} (because if I comment after this, it works).
So is there something wrong with the definition of the command?
Maybe I should define a new environment but I don't know how to do this.
Any help would be appreciated.
Regards,
Mathieu