1
0
mirror of https://github.com/specht/champ.git synced 2024-12-22 03:30:47 +00:00

parse EQU labels

This commit is contained in:
Michael Specht 2018-02-14 21:07:31 +01:00
parent c6ff6ac331
commit 4fc6ef84ac

View File

@ -324,6 +324,16 @@ class Champ
puts ' done.'
end
def parse_asm_int(s)
if s[0] == '#'
s[1, s.size - 1].to_i
elsif s[0] == '$'
s[1, s.size - 1].to_i(16)
else
s.to_i
end
end
def parse_merlin_output(path)
@source_line = -3
File.open(path, 'r') do |f|
@ -341,12 +351,6 @@ class Champ
next if code_parts.empty?
label = nil
unless @keywords.include?(code_parts.first)
label = code_parts.first
code = code.sub(label, '').strip
@label_for_pc[pc] = label
@pc_for_label[label] = pc
end
champ_directives = []
if code.include?(';')
@ -355,6 +359,20 @@ class Champ
champ_directives << match.to_s
end
end
if champ_directives.empty? && line_type == 'Equivalence'
label = code_parts[0]
pc = parse_asm_int(code_parts[2])
@label_for_pc[pc] = label
@pc_for_label[label] = pc
else
unless @keywords.include?(code_parts.first)
label = code_parts.first
code = code.sub(label, '').strip
@label_for_pc[pc] = label
@pc_for_label[label] = pc
end
end
next if champ_directives.empty?
if line_type == 'Equivalence'