2 * Simulator of microcontrollers (uc52.cc)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
10 /* This file is part of microcontroller simulator: ucsim.
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.
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.
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
39 * Making an 8052 CPU object
42 cl_uc52::cl_uc52(int Itype, int Itech, class cl_sim *asim):
43 cl_51core(Itype, Itech, asim)
49 cl_uc52::mk_hw_elements(void)
53 cl_51core::mk_hw_elements();
54 hws->add(h= new cl_timer2(this, 2, "timer2", t2_default|t2_down));
59 cl_uc52::make_memories(void)
61 class cl_address_space *as;
63 rom= as= new cl_address_space("rom", 0, 0x10000, 8);
65 address_spaces->add(as);
66 iram= as= new cl_address_space("iram", 0, 0x100, 8);
68 address_spaces->add(as);
69 sfr= as= new cl_address_space("sfr", 0x80, 0x80, 8);
71 address_spaces->add(as);
72 xram= as= new cl_address_space("xram", 0, 0x10000, 8);
74 address_spaces->add(as);
76 class cl_address_decoder *ad;
77 class cl_memory_chip *chip;
79 chip= new cl_memory_chip("rom_chip", 0x10000, 8);
82 ad= new cl_address_decoder(as= address_space("rom"), chip, 0, 0xffff, 0);
84 as->decoders->add(ad);
87 chip= new cl_memory_chip("iram_chip", 0x100, 8);
90 ad= new cl_address_decoder(as= address_space("iram"), chip, 0, 0xff, 0);
92 as->decoders->add(ad);
95 chip= new cl_memory_chip("xram_chip", 0x10000, 8);
98 ad= new cl_address_decoder(as= address_space("xram"), chip, 0, 0xffff, 0);
100 as->decoders->add(ad);
103 chip= new cl_memory_chip("sfr_chip", 0x80, 8);
106 ad= new cl_address_decoder(as= address_space("sfr"), chip, 0x80, 0xff, 0);
108 as->decoders->add(ad);
111 acc= sfr->get_cell(ACC);
112 psw= sfr->get_cell(PSW);
117 cl_uc52::clear_sfr(void)
119 cl_51core::clear_sfr();
120 sfr->write(T2CON, 0);
123 sfr->write(RCAP2L, 0);
124 sfr->write(RCAP2H, 0);
129 * Calculating address of indirectly addressed IRAM cell
133 class cl_memory_cell *
134 cl_uc52::get_indirect(uchar addr, int *res)
137 return(iram->get_cell(addr));
141 /* End of s51.src/uc52.cc */