Class: N65::Segment
- Inherits:
-
InstructionBase
- Object
- InstructionBase
- N65::Segment
- Defined in:
- lib/n65/directives/segment.rb
Overview
This directive instruction can include a binary file
Class Method Summary collapse
-
.parse(line) ⇒ Object
Try to parse a dw directive.
Instance Method Summary collapse
-
#exec(assembler) ⇒ Object
Execute the segment and bank change on the assembler.
-
#initialize(segment, bank) ⇒ Segment
constructor
Initialize with filename.
-
#to_s ⇒ Object
Display.
Methods inherited from InstructionBase
Constructor Details
#initialize(segment, bank) ⇒ Segment
Initialize with filename
23 24 25 26 |
# File 'lib/n65/directives/segment.rb', line 23 def initialize(segment, bank) @bank = bank @segment = segment end |
Class Method Details
.parse(line) ⇒ Object
Try to parse a dw directive
11 12 13 14 15 16 17 18 |
# File 'lib/n65/directives/segment.rb', line 11 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
31 32 33 34 |
# File 'lib/n65/directives/segment.rb', line 31 def exec(assembler) assembler.current_segment = @segment assembler.current_bank = @bank end |
#to_s ⇒ Object
Display
39 40 41 |
# File 'lib/n65/directives/segment.rb', line 39 def to_s ".segment #{@segment} #{@bank}" end |