ucsim-0.2.37-pre3 into cvs
[fw/sdcc] / 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 t_uc51::inst_inc_a(uchar code)
43 {
44   sfr->set(event_at.ws= ACC, sfr->get(ACC)+1);
45   return(resGO);
46 }
47
48
49 /*
50  * 0x05 2 12 INC addr
51  *____________________________________________________________________________
52  *
53  */
54
55 int
56 t_uc51::inst_inc_addr(uchar code)
57 {
58   uchar *addr;
59
60   addr= get_direct(fetch(), &event_at.wi, &event_at.ws);
61   (*addr)++;
62   proc_write(addr);
63   return(resGO);
64 }
65
66
67 /*
68  * 0x06-0x07 1 12 INC @Ri
69  *____________________________________________________________________________
70  *
71  */
72
73 int
74 t_uc51::inst_inc_$ri(uchar code)
75 {
76   uchar *addr;
77   int res;
78
79   addr= get_indirect(event_at.wi= *(get_reg(code & 0x01)), &res);
80   (*addr)++;
81   proc_write(addr);
82   return(res);
83 }
84
85
86 /*
87  * 0x08-0x0f 1 12 INC Rn
88  *____________________________________________________________________________
89  *
90  */
91
92 int
93 t_uc51::inst_inc_rn(uchar code)
94 {
95   (*(get_reg(code & 0x07, &event_at.wi)))++;
96   return(resGO);
97 }
98
99
100 /*
101  * 0x14 1 12 DEC A
102  *____________________________________________________________________________
103  *
104  */
105
106 int
107 t_uc51::inst_dec_a(uchar code)
108 {
109   sfr->set(event_at.ws= ACC, sfr->get(ACC)-1);
110   return(resGO);
111 }
112
113
114 /*
115  * 0x15 2 12 DEC addr
116  *____________________________________________________________________________
117  *
118  */
119
120 int
121 t_uc51::inst_dec_addr(uchar code)
122 {
123   uchar *addr;
124
125   addr= get_direct(fetch(), &event_at.wi, &event_at.ws);
126   (*addr)--;
127   proc_write(addr);
128   return(resGO);
129 }
130
131
132 /*
133  * 0x16-0x17 1 12 DEC @Ri
134  *____________________________________________________________________________
135  *
136  */
137
138 int
139 t_uc51::inst_dec_$ri(uchar code)
140 {
141   uchar *addr;
142   int res;
143
144   addr= get_indirect(event_at.wi= *(get_reg(code & 0x01)), &res);
145   (*addr)--;
146   proc_write(addr);
147   return(res);
148 }
149
150
151 /*
152  * 0x18-0x1f 1 12 DEC Rn
153  *____________________________________________________________________________
154  *
155  */
156
157 int
158 t_uc51::inst_dec_rn(uchar code)
159 {
160   (*(get_reg(code & 0x07, &event_at.wi)))--;
161   return(resGO);
162 }
163
164
165 /*
166  * 0xa3 1 24 INC DPTR
167  *____________________________________________________________________________
168  *
169  */
170
171 int
172 t_uc51::inst_inc_dptr(uchar code)
173 {
174   uint dptr;
175
176   dptr= sfr->get(DPH)*256 + sfr->get(DPL) + 1;
177   sfr->set(event_at.ws= DPH, (dptr >> 8) & 0xff);
178   sfr->set(DPL, dptr & 0xff);
179   tick(1);
180   return(resGO);
181 }
182
183
184 /* End of s51.src/inc.cc */