| CPU-Z80-Assembler documentation | Contained in the CPU-Z80-Assembler distribution. |
CPU::Z80::Assembler::Segment - Represents one segment of assembly opcodes
use CPU::Z80::Assembler::Segment; my $segment = CPU::Z80::Assembler::Segment->new( name => $name, address => 0, line => $line, child => [$opcode, ...]); $self->add(@opcodes);
This module defines the class that represents one continuous segment of assembly instruction opcodes CPU::Z80::Assembler::Opcode.
Nothing.
Creates a new object, see Class::Struct.
Each child is one CPU::Z80::Assembler::Opcode object.
Get/set of segment name.
Get/set of base address of the segment.
Get/set the line - text, file name and line number of the start of the segment.
Adds the opcodes to the segment. The line of the first opcode added is copied to the segment for error messages.
See CPU::Z80::Assembler.
See CPU::Z80::Assembler.
| CPU-Z80-Assembler documentation | Contained in the CPU-Z80-Assembler distribution. |
# $Id: Segment.pm,v 1.10 2010/11/21 16:40:27 Paulo Exp $ package CPU::Z80::Assembler::Segment; #------------------------------------------------------------------------------
#------------------------------------------------------------------------------ use strict; use warnings; our $VERSION = '2.13'; use Asm::Preproc::Line; #use Class::Struct ( # child => '@', # list of children of this node # line => 'Asm::Preproc::Line', # # line of first token # name => '$', # name of the segment # address => '$', # start address of segment #); sub new { my($class, %args) = @_; bless [ $args{name}, $args{address}, $args{line} || Asm::Preproc::Line->new(), $args{child} || [], ], $class; } sub name { defined($_[1]) ? $_[0][0] = $_[1] : $_[0][0] } sub address { defined($_[1]) ? $_[0][1] = $_[1] : $_[0][1] } sub line { defined($_[1]) ? $_[0][2] = $_[1] : $_[0][2] } sub child { defined($_[1]) ? $_[0][3] = $_[1] : $_[0][3] } #------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------ sub add { my($self, @opcodes) = @_; if (@opcodes) { # update line if first opcodes if (! @{$self->child}) { $self->line( $opcodes[0]->line ); } # save opcodes push(@{$self->child}, @opcodes); } } #------------------------------------------------------------------------------
#------------------------------------------------------------------------------ 1;