Files
2024-02-19 00:24:53 -05:00

48 lines
949 B
Perl

#!/usr/bin/perl
#
#
$in_block_comment = 0;
while (<>) {
if (/^\|/) {
if (! $in_block_comment) {
print "/* \n";
$in_block_comment = 1;
}
s/\|/ */;
print;
next;
} else {
if ($in_block_comment) {
print " */\n";
$in_block_comment = 0;
}
}
s/#/$/; # Convert immediate references
s/\|/#/; # Convert in-line comments
s/(\b|,)([abcd][xhl])(\b|,|$)/\1%\2\3/g;
s/(\b|,)([cdsefg]s)(\b|,|$)/\1%\2\3/g;
s/(\b|,)([sd]i)(\b|,|$)/\1%\2\3/g;
s/(\b|,)([sb]p)(\b|,|$)/\1%\2\3/g;
s/(\b|,)(e[abcd]x)(\b|,|$)/\1%\2\3/g;
if (/^(([a-zA-Z]+:[ \t]+)|[ \t]+)([a-zA-Z]+)/) {
$op = $3;
if (($op eq "mov") || ($op eq "add") || ($op eq "sub") ||
($op eq "xor") || ($op eq "and") || ($op eq "shr") ||
($op eq "shl") || ($op eq "in") || ($op eq "out")) {
#
# We need to swap arguments...
#
s/([0-9a-zA-Z%\$]+)(,)([0-9a-zA-Z%\$]+)/\3\2\1/;
}
}
print;
}