| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CPU::Emulator::Z80::Register16; |
|
2
|
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
56293
|
use strict; |
|
|
16
|
|
|
|
|
32
|
|
|
|
16
|
|
|
|
|
380
|
|
|
4
|
16
|
|
|
16
|
|
65
|
use warnings; |
|
|
16
|
|
|
|
|
28
|
|
|
|
16
|
|
|
|
|
351
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
67
|
use vars qw($VERSION); |
|
|
16
|
|
|
|
|
25
|
|
|
|
16
|
|
|
|
|
524
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
16
|
|
|
16
|
|
71
|
use base qw(CPU::Emulator::Z80::Register); |
|
|
16
|
|
|
|
|
29
|
|
|
|
16
|
|
|
|
|
1563
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
16
|
|
|
16
|
|
102
|
use CPU::Emulator::Z80::ALU; |
|
|
16
|
|
|
|
|
44
|
|
|
|
16
|
|
|
|
|
5382
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = '1.01'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
CPU::Emulator::Z80::Register16 - a 16 bit register for a Z80 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class implements a 16-bit register for a Z80. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 new |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Returns an object. Takes two or three named parameters: |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item cpu |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
mandatory, a reference to the CPU this register lives in, mostly so |
|
33
|
|
|
|
|
|
|
that operations on the register can get at the flags register. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=back |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
and either of: |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item value |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
The value to initialise the register to; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=back |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
or |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=over |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item get, set |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Subroutines to call when getting/setting the register instead of |
|
54
|
|
|
|
|
|
|
the default get/set methods. The 'get' subroutine will be passed |
|
55
|
|
|
|
|
|
|
no parameters, the 'set' subroutine will be passed the new value. |
|
56
|
|
|
|
|
|
|
Consequently, they are expected to be closures if they are to be |
|
57
|
|
|
|
|
|
|
of any use. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=back |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub new { |
|
64
|
17070
|
|
|
17070
|
1
|
71770
|
my $class = shift; |
|
65
|
17070
|
|
|
|
|
39560
|
my $self = {@_, bits => 16}; |
|
66
|
17070
|
|
|
|
|
23037
|
$self->{bits} = 16; |
|
67
|
17070
|
|
|
|
|
51651
|
bless $self, $class; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 get |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Get the register's current value. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub get { |
|
77
|
36302
|
|
|
36302
|
1
|
199729
|
my $self = shift; |
|
78
|
36302
|
100
|
|
|
|
53716
|
if(exists($self->{get})) { |
|
79
|
7972
|
|
|
|
|
15454
|
return $self->{get}->(); |
|
80
|
28330
|
|
|
|
|
61467
|
} else { return $self->{value} & 0xFFFF } |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 set |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Set the register's value to whatever is passed in as a parameter. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub set { |
|
90
|
24659
|
|
|
24659
|
1
|
127352
|
my $self = shift; |
|
91
|
24659
|
100
|
|
|
|
36746
|
if(exists($self->{set})) { |
|
92
|
7838
|
|
|
|
|
14752
|
return $self->{set}->(shift); |
|
93
|
16821
|
|
|
|
|
32230
|
} else { $self->{value} = shift() & 0xFFFF } |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 add |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Add the specified value to the register, frobbing flags |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub add { |
|
103
|
20
|
|
|
20
|
1
|
55
|
my($self, $op, $adc) = @_; |
|
104
|
|
|
|
|
|
|
# $adc tells us if this is really ADC |
|
105
|
20
|
|
|
|
|
104
|
$self->set( |
|
106
|
|
|
|
|
|
|
ALU_add16($self->cpu()->register('F'), $self->get(), $op, $adc) |
|
107
|
|
|
|
|
|
|
); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 sub |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Subtract the specified value from the register. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub sub { |
|
117
|
31
|
|
|
31
|
1
|
195
|
my($self, $op) = @_; |
|
118
|
31
|
|
|
|
|
80
|
$self->set(ALU_sub16($self->cpu()->register('F'), $self->get(), $op)); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 inc, dec |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
These use the implementation from the parent class |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 BUGS/WARNINGS/LIMITATIONS |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
None known. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT and LICENCE |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2008 David Cantrell EFE |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This software is free-as-in-speech software, and may be used, |
|
134
|
|
|
|
|
|
|
distributed, and modified under the terms of either the GNU |
|
135
|
|
|
|
|
|
|
General Public Licence version 2 or the Artistic Licence. It's |
|
136
|
|
|
|
|
|
|
up to you which one you use. The full text of the licences can |
|
137
|
|
|
|
|
|
|
be found in the files GPL2.txt and ARTISTIC.txt, respectively. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 CONSPIRACY |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This module is also free-as-in-mason software. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; |