Created
February 10, 2012 01:04
-
-
Save mnaberez/1784947 to your computer and use it in GitHub Desktop.
Generate VICE monitor labels from an XAsm listing file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Ruby script to generate VICE monitor labels from | |
# an XAsm listing file. | |
filename = ARGV[0] | |
if filename | |
lines = File.readlines(filename) | |
else | |
abort "Usage: vice-labels.rb <filename>" | |
end | |
# Collect the lines containing the symbol table | |
symbol_lines = [] | |
started = false | |
lines.each do |line| | |
if line.include?("***Symbol Listing") | |
started = true | |
elsif line.include?("error(s)") | |
break | |
elsif started && !line.strip.empty? | |
symbol_lines << line | |
end | |
end | |
# Parse the symbol table into a hash: {address => label} | |
addr_label={} | |
symbol_lines.each do |line| | |
line.scan(/(\w+)\s+(\w+)/).each do |label, addr| | |
addr_label[addr] = label | |
end | |
end | |
# Generate VICE monitor labels ordered by address | |
addr_label.keys.sort.each do |addr| | |
label = addr_label[addr] | |
puts "add_label $#{addr} .#{label}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment