summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-05-23 16:59:59 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-05-23 16:59:59 -0700
commitea2832c7f307f157af53a65cf347752fd83a9aef (patch)
treedb6b6b45e1583d6cd89063b8ab33d8efa7281960
parent072771e4a51c8794ce7a279da76f22bd4ba37957 (diff)
downloadnasm-ea2832c7f307f157af53a65cf347752fd83a9aef.tar.gz
nasm-ea2832c7f307f157af53a65cf347752fd83a9aef.tar.bz2
nasm-ea2832c7f307f157af53a65cf347752fd83a9aef.zip
fmtinsns.pl: handle compiler fields; do some case mangling
Handle compiler-generated fields, and at least try to do some case mangling.
-rwxr-xr-xmisc/fmtinsns.pl21
1 files changed, 15 insertions, 6 deletions
diff --git a/misc/fmtinsns.pl b/misc/fmtinsns.pl
index 9acde06..848ee2d 100755
--- a/misc/fmtinsns.pl
+++ b/misc/fmtinsns.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# Re-align the columns in insns.dat
+# Re-align the columns in insns.dat, and enforce case conventions
#
@cols = (0, 16, 48, 96);
@@ -9,21 +9,30 @@ while ($line = <STDIN>) {
chomp $line;
if ($line !~ /^\s*(\;.*|)$/) {
($ln = $line) =~ s/\s+$//;
- @fields = split(/\s+/, $line);
- if (scalar(@fields) == 4) {
+ if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
+ @fields = ($1, $2, $3, $4);
+ $fields[0] = "\U$fields[0]" unless ($fields[0] =~ /^[^a-z]+cc$/);
+ $fields[3] =~ s/\,+$//;
+ $fields[3] = "\U$fields[3]" unless ($fields[3] eq 'ignore');
$c = 0;
$line = '';
for ($i = 0; $i < scalar(@fields); $i++) {
if ($i > 0 && $c >= $cols[$i]) {
$line .= ' ';
$c++;
- }
+ }
while ($c < $cols[$i]) {
$line .= "\t";
- $c = ($c+8) & ~7;
+ $c = ($c+8) & ~7;
}
$line .= $fields[$i];
- $c += length($fields[$i]);
+ for ($j = 0; $j < length($fields[$i]); $j++) {
+ if (substr($fields[$i], $j, 1) eq "\t") {
+ $c = ($c+8) & ~7;
+ } else {
+ $c++;
+ }
+ }
}
}
}