A healthy dose of sillyness
[retty.git] / bytecode.pl
blob4f7a63e5f76642563093bb93f74cc637ddc6c52c
1 #!/usr/bin/perl
3 # 'There are evil things written on this hilt,' he said; 'though maybe your
4 # eyes cannot see them. Keep it, Aragorn, till we reach the house of Elrond!
5 # But be wary, and handle it as little as you may! Alas! the wounds of this
6 # weapon are beyond my skill to heal. I will do what I can - but all the more
7 # do I urge you now to go on without rest.'
9 $state = 0;
10 while ($l = <STDIN>) {
11 chomp($l);
12 if (!$state && $l =~ /^[0-9a-f]* <.*>:/) {
13 $state++;
14 } elsif ($state) {
15 if ($l =~ /^\s*([0-9a-f]*):\t(.*)\t(.*)$/) {
16 $c = $1;
17 $a = $2;
18 $b = $3;
19 $a =~ s/[^0-9a-f]//g;
20 $a =~ s/([0-9a-f]{2})/0x\1,/g;
21 printf("/* %04s */\t%-30s\t/* \%s */\n", $c, $a, $b);
22 } elsif ($l =~ /^([0-9a-f]+) <(\S+)>:\s*$/) {
23 push (@id, [$2, $1]);
28 print "};\n";
29 foreach my $i (@id) {
30 my ($id, $ofs) = @$i;
31 print "poke_32($ARGV[0], 0x$ofs+1, fd_$id);\n";
33 print "{\n";