Move all the RAA code out of nasmlib
[nasm/autotest.git] / misc / fmtinsns.pl
blob848ee2de026a03a5b46b5bf19cfc7aa55beeaaf2
1 #!/usr/bin/perl
3 # Re-align the columns in insns.dat, and enforce case conventions
6 @cols = (0, 16, 48, 96);
8 while ($line = <STDIN>) {
9 chomp $line;
10 if ($line !~ /^\s*(\;.*|)$/) {
11 ($ln = $line) =~ s/\s+$//;
12 if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
13 @fields = ($1, $2, $3, $4);
14 $fields[0] = "\U$fields[0]" unless ($fields[0] =~ /^[^a-z]+cc$/);
15 $fields[3] =~ s/\,+$//;
16 $fields[3] = "\U$fields[3]" unless ($fields[3] eq 'ignore');
17 $c = 0;
18 $line = '';
19 for ($i = 0; $i < scalar(@fields); $i++) {
20 if ($i > 0 && $c >= $cols[$i]) {
21 $line .= ' ';
22 $c++;
24 while ($c < $cols[$i]) {
25 $line .= "\t";
26 $c = ($c+8) & ~7;
28 $line .= $fields[$i];
29 for ($j = 0; $j < length($fields[$i]); $j++) {
30 if (substr($fields[$i], $j, 1) eq "\t") {
31 $c = ($c+8) & ~7;
32 } else {
33 $c++;
39 print $line, "\n";