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:
parent
c6ff6ac331
commit
4fc6ef84ac
30
champ.rb
30
champ.rb
@ -324,6 +324,16 @@ class Champ
|
|||||||
puts ' done.'
|
puts ' done.'
|
||||||
end
|
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)
|
def parse_merlin_output(path)
|
||||||
@source_line = -3
|
@source_line = -3
|
||||||
File.open(path, 'r') do |f|
|
File.open(path, 'r') do |f|
|
||||||
@ -341,12 +351,6 @@ class Champ
|
|||||||
next if code_parts.empty?
|
next if code_parts.empty?
|
||||||
|
|
||||||
label = nil
|
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 = []
|
champ_directives = []
|
||||||
if code.include?(';')
|
if code.include?(';')
|
||||||
@ -355,6 +359,20 @@ class Champ
|
|||||||
champ_directives << match.to_s
|
champ_directives << match.to_s
|
||||||
end
|
end
|
||||||
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?
|
next if champ_directives.empty?
|
||||||
|
|
||||||
if line_type == 'Equivalence'
|
if line_type == 'Equivalence'
|
||||||
|
Loading…
Reference in New Issue
Block a user