23 my @flagnames = ('SF', 'CF', 'OF', 'ZF');
24 my $section = "\\subsubsection";
30 @fields = split(/\|/, $_[3]);
31 foreach my $field (@fields) {
32 #remove heading and trailing spaces
37 #$tabular .= $field." \\\\";
41 return "Num of Fields not equal to Bits!";
44 @fieldnames = split(/\|/, $_[4]);
46 if(scalar(@fields) != scalar(@fieldnames)) {
47 return "Num of Fields != Num of Names";
51 foreach my $fieldn (@fieldnames) {
52 #remove heading and trailing spaces
56 if($fieldn =~ m/^[^\(.]*\(\s*([0-1]+)\s*\).*$/) {
57 if(length($1) == $fields[$count]) {
58 push(@bitlist,'S'.$1);
59 $fieldn =~ s/\s?\(\s*[0-1]+\s*\)//;
71 #$tabular .= $fieldn.": ". $bits." \\\\";
75 #$tabular .= "\\textbf{names:} @fieldnames \n";
76 #$tabular .= "\\textbf{bitlist:} $bitlist \n";
80 $tabular = $section."{\\texttt{".$_[1]."} -- ".$_[2]."}\n";
81 $tabular .= "\\begin{center} \n \\resizebox{\\textwidth}{!}{\n";
82 $tabular .= "\\begin{tabular}{|l|";
83 for($i = $bits-1; $i >= 0; $i--) {
93 $bline .= "\\\\ \\hline \n";
96 #build nameline and bitvalue
97 #because of multicolumn we need to limit execution
99 $nline .= "\\multicolumn{@fields[0]}{>{\\columncolor{names}}c|}{@fieldnames[0]}";
101 if(substr(@bitlist[0],0,1) eq "L") {
102 $vline .= "\\multicolumn{@fields[0]}{>{\\columncolor{bitval}}c|}{".substr(@bitlist[0],1)."}";
105 for(my $j = 1; $j <= @fields[0]; $j++) {
106 $vline .= substr(@bitlist[0],$j,1);
107 if($j != @fields[0]) {
114 $count -= @fields[0];
117 $nline .= "\\\\ \\hline \n";
118 $vline .= "\\\\ \\hline \n";
130 $tabular .= "} \\hline \n";
131 $tabular .= "\\multicolumn{".($bits+1)."}{|>{\\columncolor{title}}c|}{\\textbf{".$_[1]."} (".$_[2].")} \\\\ \\hline \n";
132 $tabular .= "\\rowcolor{bit} \\cellcolor{title} &". $bline;
134 $tabular .= "\\rowcolor{bitval} \\cellcolor{title}Values &". $vline;
136 $tabular .= "\\cellcolor{title}Field &". $nline;
137 $tabular .= "\\end{tabular}\n}\n \\end{center}\n";
140 $tabular .= "\\paragraph{Description:}~\\\\ \n ".$_[5]. "\n";
145 my @flags = split(/\|/, $_[6]);
147 if(scalar(@flags) == scalar(@flagnames)) {
148 $tabular .= "\\paragraph{Flags:} \n";
150 foreach my $flag (@flags) {
151 #remove heading and trailing spaces
154 if(length($flag) > 0 ) {
155 $tabular .= "\\subparagraph{".$flagnames[$count].":} ".$flag." \n";
164 $tabular .= "\\paragraph{Example:}~\\\\ \n \\begin{lstlisting} \n ".$_[7]. " \\end{lstlisting}\n";
170 print "\\paragraph{Aliases to this Instruction:} \n";
171 my @aliases = split(/\|/, $_[8]);
173 print "\\begin{list}{\\labelitemi}{\\leftmargin=0em \\itemindent=1em}";
176 foreach my $alias (@aliases) {
180 my $namelist = $_[4];
182 @params = split(/-/, $alias);
185 shift(@params); shift(@params);
187 foreach my $vals (@params) {
190 ($field, $val) = split(/\//, $vals);
192 my @fieldnames = split(/\|/, $namelist);
194 $fieldnames[$field] = $fieldnames[$field]."(".$val.")";
195 $namelist = join("|",@fieldnames);
198 ins($_[0], $sub, $long,$_[3], $namelist, '', '', '', '',1);
206 die "Usage: gentex.pl <file.ptex>";
209 my $output = $ARGV[0];
210 my $input = $ARGV[0];
212 $output =~ s/\.[^.]*$//;
215 open STDOUT, '>', $output or die "Can't redirect STDOUT: $!";