line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package CPU::Z80::Assembler::Segment; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
CPU::Z80::Assembler::Segment - Represents one segment of assembly opcodes |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
14
|
|
|
|
|
|
|
|
15
|
31
|
|
|
31
|
|
257
|
use strict; |
|
31
|
|
|
|
|
76
|
|
|
31
|
|
|
|
|
1306
|
|
16
|
31
|
|
|
31
|
|
203
|
use warnings; |
|
31
|
|
|
|
|
73
|
|
|
31
|
|
|
|
|
1772
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '2.24'; |
19
|
|
|
|
|
|
|
|
20
|
31
|
|
|
31
|
|
197
|
use Asm::Preproc::Line; |
|
31
|
|
|
|
|
71
|
|
|
31
|
|
|
|
|
347
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#use Class::Struct ( |
23
|
|
|
|
|
|
|
# child => '@', # list of children of this node |
24
|
|
|
|
|
|
|
# line => 'Asm::Preproc::Line', |
25
|
|
|
|
|
|
|
# # line of first token |
26
|
|
|
|
|
|
|
# name => '$', # name of the segment |
27
|
|
|
|
|
|
|
# address => '$', # start address of segment |
28
|
|
|
|
|
|
|
#); |
29
|
|
|
|
|
|
|
sub new { |
30
|
2794
|
|
|
2794
|
1
|
10455
|
my($class, %args) = @_; |
31
|
|
|
|
|
|
|
bless [ |
32
|
|
|
|
|
|
|
$args{name}, |
33
|
|
|
|
|
|
|
$args{address}, |
34
|
|
|
|
|
|
|
$args{line} || Asm::Preproc::Line->new(), |
35
|
2794
|
|
33
|
|
|
12436
|
$args{child} || [], |
|
|
|
50
|
|
|
|
|
36
|
|
|
|
|
|
|
], $class; |
37
|
|
|
|
|
|
|
} |
38
|
43
|
50
|
|
43
|
1
|
268
|
sub name { defined($_[1]) ? $_[0][0] = $_[1] : $_[0][0] } |
39
|
36064
|
100
|
|
36064
|
1
|
99812
|
sub address { defined($_[1]) ? $_[0][1] = $_[1] : $_[0][1] } |
40
|
2812
|
100
|
|
2812
|
1
|
16351
|
sub line { defined($_[1]) ? $_[0][2] = $_[1] : $_[0][2] } |
41
|
99448
|
50
|
|
99448
|
1
|
264578
|
sub child { defined($_[1]) ? $_[0][3] = $_[1] : $_[0][3] } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use CPU::Z80::Assembler::Segment; |
48
|
|
|
|
|
|
|
my $segment = CPU::Z80::Assembler::Segment->new( |
49
|
|
|
|
|
|
|
name => $name, |
50
|
|
|
|
|
|
|
address => 0, |
51
|
|
|
|
|
|
|
line => $line, |
52
|
|
|
|
|
|
|
child => [$opcode, ...]); |
53
|
|
|
|
|
|
|
$self->add(@opcodes); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This module defines the class that represents one continuous segment of assembly |
58
|
|
|
|
|
|
|
instruction opcodes L. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 EXPORTS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Nothing. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 FUNCTIONS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 new |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Creates a new object, see L. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 child |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Each child is one L object. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 name |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Get/set of segment name. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 address |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Get/set of base address of the segment. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 line |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Get/set the line - text, file name and line number of the start of the segment. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 add |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Adds the opcodes to the segment. The line of the first opcode added is copied to |
93
|
|
|
|
|
|
|
the segment for error messages. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub add { |
100
|
19451
|
|
|
19451
|
1
|
40229
|
my($self, @opcodes) = @_; |
101
|
|
|
|
|
|
|
|
102
|
19451
|
100
|
|
|
|
44287
|
if (@opcodes) { |
103
|
|
|
|
|
|
|
# update line if first opcodes |
104
|
19450
|
100
|
|
|
|
28312
|
if (! @{$self->child}) { |
|
19450
|
|
|
|
|
38249
|
|
105
|
2789
|
|
|
|
|
7851
|
$self->line( $opcodes[0]->line ); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# save opcodes |
109
|
19450
|
|
|
|
|
31697
|
push(@{$self->child}, @opcodes); |
|
19450
|
|
|
|
|
35634
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 BUGS and FEEDBACK |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
See L. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SEE ALSO |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L |
122
|
|
|
|
|
|
|
L |
123
|
|
|
|
|
|
|
L |
124
|
|
|
|
|
|
|
L |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHORS, COPYRIGHT and LICENCE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
See L. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |