Imported Upstream version 2.9.0
[debian/cc1111] / sim / ucsim / s51.src / inc.cc
1 /*
2  * Simulator of microcontrollers (inc.cc)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING.  If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
27
28 #include "ddconfig.h"
29
30 // local
31 #include "uc51cl.h"
32 #include "regs51.h"
33
34
35 /*
36  * 0x04 1 12 INC A
37  *____________________________________________________________________________
38  *
39  */
40
41 int
42 cl_51core::inst_inc_a(uchar code)
43 {
44   acc->wadd(1);
45   return(resGO);
46 }
47
48
49 /*
50  * 0x05 2 12 INC addr
51  *____________________________________________________________________________
52  *
53  */
54
55 int
56 cl_51core::inst_inc_addr(uchar code)
57 {
58   class cl_memory_cell *cell= get_direct(fetch());
59
60   t_mem d= cell->read(HW_PORT);
61   cell->write(d+1);
62   return(resGO);
63 }
64
65
66 /*
67  * 0x06-0x07 1 12 INC @Ri
68  *____________________________________________________________________________
69  *
70  */
71
72 int
73 cl_51core::inst_inc_Sri(uchar code)
74 {
75   class cl_memory_cell *cell;
76
77   cell= iram->get_cell(get_reg(code & 0x01)->read());
78   cell->wadd(1);
79   return(resGO);
80 }
81
82
83 /*
84  * 0x08-0x0f 1 12 INC Rn
85  *____________________________________________________________________________
86  *
87  */
88
89 int
90 cl_51core::inst_inc_rn(uchar code)
91 {
92   class cl_memory_cell *reg= get_reg(code & 0x07);
93
94   reg->wadd(1);
95   return(resGO);
96 }
97
98
99 /*
100  * 0x14 1 12 DEC A
101  *____________________________________________________________________________
102  *
103  */
104
105 int
106 cl_51core::inst_dec_a(uchar code)
107 {
108   acc->wadd(-1);
109
110   return(resGO);
111 }
112
113
114 /*
115  * 0x15 2 12 DEC addr
116  *____________________________________________________________________________
117  *
118  */
119
120 int
121 cl_51core::inst_dec_addr(uchar code)
122 {
123   class cl_memory_cell *cell;
124
125   cell= get_direct(fetch());
126   t_mem d= cell->read(HW_PORT);
127   cell->write(d-1);
128   return(resGO);
129 }
130
131
132 /*
133  * 0x16-0x17 1 12 DEC @Ri
134  *____________________________________________________________________________
135  *
136  */
137
138 int
139 cl_51core::inst_dec_Sri(uchar code)
140 {
141   class cl_memory_cell *cell;
142
143   cell= iram->get_cell(get_reg(code & 0x01)->read());
144   cell->add(-1);
145   return(resGO);
146 }
147
148
149 /*
150  * 0x18-0x1f 1 12 DEC Rn
151  *____________________________________________________________________________
152  *
153  */
154
155 int
156 cl_51core::inst_dec_rn(uchar code)
157 {
158   class cl_memory_cell *reg= get_reg(code & 0x07);
159
160   reg->wadd(-1);
161   return(resGO);
162 }
163
164
165 /*
166  * 0xa3 1 24 INC DPTR
167  *____________________________________________________________________________
168  *
169  */
170
171 int
172 cl_51core::inst_inc_dptr(uchar code)
173 {
174   uint dptr;
175
176   dptr= sfr->read(DPH)*256 + sfr->read(DPL) + 1;
177   sfr->write(DPH, (dptr >> 8) & 0xff);
178   sfr->write(DPL, dptr & 0xff);
179   tick(1);
180   return(resGO);
181 }
182
183
184 /* End of s51.src/inc.cc */