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
|
|
241
|
use strict; |
|
31
|
|
|
|
|
90
|
|
|
31
|
|
|
|
|
1305
|
|
16
|
31
|
|
|
31
|
|
186
|
use warnings; |
|
31
|
|
|
|
|
84
|
|
|
31
|
|
|
|
|
1932
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '2.23'; |
19
|
|
|
|
|
|
|
|
20
|
31
|
|
|
31
|
|
259
|
use Asm::Preproc::Line; |
|
31
|
|
|
|
|
82
|
|
|
31
|
|
|
|
|
344
|
|
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
|
9807
|
my($class, %args) = @_; |
31
|
|
|
|
|
|
|
bless [ |
32
|
|
|
|
|
|
|
$args{name}, |
33
|
|
|
|
|
|
|
$args{address}, |
34
|
|
|
|
|
|
|
$args{line} || Asm::Preproc::Line->new(), |
35
|
2794
|
|
33
|
|
|
15902
|
$args{child} || [], |
|
|
|
50
|
|
|
|
|
36
|
|
|
|
|
|
|
], $class; |
37
|
|
|
|
|
|
|
} |
38
|
43
|
50
|
|
43
|
1
|
246
|
sub name { defined($_[1]) ? $_[0][0] = $_[1] : $_[0][0] } |
39
|
36064
|
100
|
|
36064
|
1
|
98323
|
sub address { defined($_[1]) ? $_[0][1] = $_[1] : $_[0][1] } |
40
|
2812
|
100
|
|
2812
|
1
|
15672
|
sub line { defined($_[1]) ? $_[0][2] = $_[1] : $_[0][2] } |
41
|
99448
|
50
|
|
99448
|
1
|
275303
|
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
|
40505
|
my($self, @opcodes) = @_; |
101
|
|
|
|
|
|
|
|
102
|
19451
|
100
|
|
|
|
42553
|
if (@opcodes) { |
103
|
|
|
|
|
|
|
# update line if first opcodes |
104
|
19450
|
100
|
|
|
|
28157
|
if (! @{$self->child}) { |
|
19450
|
|
|
|
|
39199
|
|
105
|
2789
|
|
|
|
|
8025
|
$self->line( $opcodes[0]->line ); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# save opcodes |
109
|
19450
|
|
|
|
|
32107
|
push(@{$self->child}, @opcodes); |
|
19450
|
|
|
|
|
33575
|
|
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; |