Skip to content

Latest commit

 

History

History
executable file
·
25 lines (21 loc) · 567 Bytes

cvtasm.pl

File metadata and controls

executable file
·
25 lines (21 loc) · 567 Bytes
 
Oct 27, 2016
Oct 27, 2016
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl -w
# run this on the output from ndisasm.
use warnings;
use strict;
while (<>) {
chomp;
my ($bytes, $asm) = /\A.*?\s+(.*?)\s+(.*)\Z/;
my $first = 1;
while ($bytes ne '') {
$bytes =~ s/\A(..)//;
my $hex = $1;
if ($first and ($bytes eq '')) {
print(" *(ptr++) = 0x$hex; /* $asm */\n");
} elsif ($first) {
print(" *(ptr++) = 0x$hex; /* $asm... */\n");
} else {
print(" *(ptr++) = 0x$hex; /* ...$asm */\n");
}
$first = 0;
}
}