2 * Simulator of microcontrollers (uc390.cc)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
8 * uc390.cc - module created by Karl Bongers 2001, karl@turbobit.com
11 /* This file is part of microcontroller simulator: ucsim.
13 UCSIM is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 UCSIM is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with UCSIM; see the file COPYING. If not, write to the Free
25 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
38 * Making an 390 CPU object
41 t_uc390::t_uc390(int Itype, int Itech, class cl_sim *asim):
42 t_uc52(Itype, Itech, asim)
48 *____________________________________________________________________________
52 t_uc390::inst_inc_addr(uchar code)
56 addr= get_direct(fetch(), &event_at.wi, &event_at.ws);
58 /* mask off the 2Hex bit adjacent to the 1H bit which selects
59 which DPTR we use. This is a feature of 80C390.
60 You can do INC DPS and it only effects bit 1. */
62 (*addr) ^= 1; /* just toggle */
73 *____________________________________________________________________________
78 t_uc390::inst_inc_dptr(uchar code)
82 unsigned char pl,ph,dps;
93 if (dps & 1) { /* alternate DPTR */
94 if (dps & 0x80) /* decr set */
95 dptr= sfr->get(ph)*256 + sfr->get(pl) - 1;
97 dptr= sfr->get(ph)*256 + sfr->get(pl) + 1;
99 if (dps & 0x40) /* decr set */
100 dptr= sfr->get(ph)*256 + sfr->get(pl) - 1;
102 dptr= sfr->get(ph)*256 + sfr->get(pl) + 1;
105 sfr->set(event_at.ws= ph, (dptr >> 8) & 0xff);
106 sfr->set(pl, dptr & 0xff);
108 if (dps & 0x20) { /* auto-switch dptr */
109 sfr->set(DPS, (dps ^ 1)); /* toggle dual-dptr switch */
116 * 0x73 1 24 JMP @A+DPTR
117 *____________________________________________________________________________
122 t_uc390::inst_jmp_$a_dptr(uchar code)
124 unsigned char pl,ph,dps;
135 PC= (sfr->get(ph)*256 + sfr->get(pl) +
136 read_mem(MEM_SFR, ACC)) &
144 * 0x90 3 24 MOV DPTR,#data
145 *____________________________________________________________________________
150 t_uc390::inst_mov_dptr_$data(uchar code)
152 unsigned char pl,ph,dps;
163 sfr->set(event_at.ws= ph, fetch());
164 sfr->set(pl, fetch());
166 if (dps & 0x20) { /* auto-switch dptr */
167 sfr->set(DPS, (dps ^ 1)); /* toggle dual-dptr switch */
176 * 0x93 1 24 MOVC A,@A+DPTR
177 *____________________________________________________________________________
182 t_uc390::inst_movc_a_$a_dptr(uchar code)
184 unsigned char pl,ph,dps;
195 sfr->set(ACC, get_mem(MEM_ROM, event_at.rc=
196 (sfr->get(ph)*256+sfr->get(pl) +
197 sfr->get(ACC)) & (EROM_SIZE-1)));
200 if (dps & 0x10) { /* auto-incr */
202 t = (sfr->get(pl) + 1) & 0xff;
204 if (t == 0) { /* overflow */
205 t = (sfr->get(ph) + 1) & 0xff;
211 if (dps & 0x20) { /* auto-switch dptr */
212 sfr->set(DPS, (dps ^ 1)); /* toggle dual-dptr switch */
220 * 0xe0 1 24 MOVX A,@DPTR
221 *____________________________________________________________________________
226 t_uc390::inst_movx_a_$dptr(uchar code)
228 unsigned char pl,ph,dps;
239 sfr->set(event_at.ws= ACC,
240 get_mem(MEM_XRAM, event_at.rx=sfr->get(ph)*256+sfr->get(pl)));
243 if (dps & 0x10) { /* auto-incr */
245 t = (sfr->get(pl) + 1) & 0xff;
247 if (t == 0) { /* overflow */
248 t = (sfr->get(ph) + 1) & 0xff;
254 if (dps & 0x20) { /* auto-switch dptr */
255 sfr->set(DPS, (dps ^ 1)); /* toggle dual-dptr switch */
262 * 0xf0 1 24 MOVX @DPTR,A
263 *____________________________________________________________________________
268 t_uc390::inst_movx_$dptr_a(uchar code)
270 unsigned char pl,ph,dps;
281 set_mem(MEM_XRAM, event_at.wx= sfr->get(ph)*256+sfr->get(pl),
282 sfr->get(event_at.rs= ACC));
285 if (dps & 0x10) { /* auto-incr */
287 t = (sfr->get(pl) + 1) & 0xff;
289 if (t == 0) { /* overflow */
290 t = (sfr->get(ph) + 1) & 0xff;
296 if (dps & 0x20) { /* auto-switch dptr */
297 sfr->set(DPS, (dps ^ 1)); /* toggle dual-dptr switch */
305 /* End of s51.src/uc390.cc */