1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/perl -w while(<>) { chomp; s/;.*//; next if /^\s*$/; ($label, $addr) = (/^(\S+)\s+=\s+\$(\S+)/); $addr = eval "0x$addr"; $got{$addr} = $label; } for (sort { $a <=> $b } keys %got) { $addr = sprintf("%04x", $_); print <<EOF; label { name "$got{$_}"; addr \$$addr; }; EOF }