Class: N65::Segment

Inherits:
InstructionBase show all
Defined in:
lib/n65/directives/segment.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from InstructionBase

#unresolved_symbols?

Constructor Details

#initialize(segment, bank) ⇒ Segment

Initialize with filename



16
17
18
19
# File 'lib/n65/directives/segment.rb', line 16

def initialize(segment, bank)
  @bank = bank
  @segment = segment
end

Class Method Details

.parse(line) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/n65/directives/segment.rb', line 6

def self.parse(line)
  match_data = line.match(/^.segment (prog|char) (\d+)$/i)
  unless match_data.nil?
    _, segment, bank = match_data.to_a
    return Segment.new(segment, bank.to_i)
  end
  nil
end

Instance Method Details

#exec(assembler) ⇒ Object

Execute the segment and bank change on the assembler



22
23
24
25
# File 'lib/n65/directives/segment.rb', line 22

def exec(assembler)
  assembler.current_segment = @segment
  assembler.current_bank = @bank
end

#to_sObject



27
28
29
# File 'lib/n65/directives/segment.rb', line 27

def to_s
  ".segment #{@segment} #{@bank}"
end