[ucsim] Update email and file info, fix stm8 flash controller
[sdcc.git] / sdcc / sim / ucsim / src / sims / m68hc12.src / m68hc12cl.h
blob6744c3ecd39a40282f932193675cdb4ee2c7a537
1 /*
2 * Simulator of microcontrollers (m68hc12cl.h)
4 * Copyright (C) 2020 Drotos Daniel
5 *
6 * To contact author send email to dr.dkdb@gmail.com
8 */
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
25 02111-1307, USA. */
26 /*@1@*/
28 #ifndef M68HC12CL_HEADER
29 #define M68HC12CL_HEADER
31 #include "uccl.h"
32 #include "memcl.h"
34 #include "m68hc11cl.h"
36 #define CL12 cl_m68hc12
38 class CL12;
39 class cl_hc12_cpu;
41 typedef int (*hcwrapper_fn)(class CL12 *uc, t_mem code);
43 enum {
44 flagStop = 0x80,
45 flagX = 0x40
48 #define rTMP2 (TMP2)
49 #define rTMP3 (TMP3)
52 * Special handling of CCR
55 class cl_ccr: public cl_cell8
57 public:
58 virtual t_mem write(t_mem val);
63 * Base of M68HC12 processor
65 * uc -> m6800 -> m68hcbase -> m68hc12
66 * A,B,CC,X,SP D,Y
69 class cl_m68hc12: public cl_m68hcbase
71 public:
72 //i8_t post_inc_dec;
73 //class cl_cell16 *post_idx_reg;
74 class cl_wrap *hc12wrap;
75 u16_t TMP2, TMP3;
76 class cl_cell16 cTMP2, cTMP3;
77 class cl_memory_cell *tex_cells[8], *loop_cells[8];
78 const char *tex_names[8], *loop_names[8];
79 u16_t XIRQ_AT, COP_AT, TRAP_AT, CMR_AT;
80 class cl_hc12_cpu *cpu12;
81 int extra_ticks, xb_tick_shift;
82 bool block_irq;
83 u8_t rev_st, rd_Rx, Rx, rd_Fy, Fy; // REV state
84 public:
85 cl_m68hc12(class cl_sim *asim);
86 virtual int init(void);
87 virtual const char *id_string(void);
88 virtual void reset(void);
89 virtual void make_memories(void);
90 virtual void setup_ccr(void) {}
91 virtual void make_cpu_hw(void);
93 virtual double def_xtal(void) { return 8000000; }
95 virtual int proba(int,t_mem);
96 virtual int prob1(int,t_mem) {return 1;}
98 virtual struct dis_entry *dis_tbl(void);
99 virtual struct dis_entry *get_dis_entry(t_addr addr);
100 virtual char *disassc(t_addr addr, chars *comment=NULL);
101 virtual void disass_xb(t_addr *addr, chars *work, chars *comment, int len, int corr= 0, u32_t use_PC=0);
102 virtual void disass_b7(t_addr *addr, chars *work, chars *comment);
103 virtual char *disass_loop(t_addr *addr, chars *work, chars *comment);
105 virtual int inst_length(t_addr addr);
106 virtual int longest_inst(void) { return 6; }
108 virtual void pre_inst(void);
109 virtual void pre_emu(void);
110 virtual int exec_inst(void);
111 virtual void post_inst(void);
112 virtual void post_emu(void);
113 virtual i16_t s8_16(u8_t op); // sex 8->16
114 virtual int xb_type(u8_t p);
115 virtual bool xb_indirect(u8_t p);
116 virtual bool xb_PC(u8_t p);
117 virtual t_addr naddr(t_addr *addr, u8_t *pg, u32_t use_PC= 0);
118 virtual u8_t xbop8();
119 virtual u16_t xbop16();
120 virtual class cl_memory_cell &xb(void);
121 virtual class cl_memory_cell &xbdst(void) { vc.wr++; return xb(); }
122 virtual t_addr xbaddr(void) { return naddr(NULL, NULL); }
123 virtual void print_regs(class cl_console_base *con);
125 virtual void push_regs(bool inst_part);
126 virtual void pull_regs(bool inst_part);
127 virtual int exec_b7(void);
128 virtual int trap(t_mem code);
130 // ALU
131 virtual int sub16(class cl_cell16 &dest, u16_t op);
132 virtual int add16(class cl_cell16 &dest, u16_t op);
133 virtual int cp16(u16_t op1, u16_t op2);
134 virtual int lsr16(class cl_memory_cell &dest);
135 virtual int asl16(class cl_memory_cell &dest);
136 virtual int inxy(class cl_memory_cell &dest);
137 virtual int dexy(class cl_memory_cell &dest);
138 virtual int ediv(void);
139 virtual int mul(void);
140 virtual int emul(void);
141 virtual int daa(void);
142 virtual int idiv(void);
143 virtual int fdiv(void);
144 virtual int emacs(void);
145 virtual int emuls(void);
146 virtual int edivs(void);
147 virtual int idivs(void);
148 virtual int maxa(void);
149 virtual int mina(void);
150 virtual int emaxd(void);
151 virtual int emind(void);
152 virtual int maxm(void);
153 virtual int minm(void);
154 virtual int emaxm(void);
155 virtual int eminm(void);
156 virtual int tbl(void);
157 virtual int etbl(void);
158 virtual int mem(void);
159 virtual int rev(void);
161 // MOVE
162 #define ld16 ldsx
163 virtual int i_psh8(u8_t op);
164 virtual int i_pul8(class cl_memory_cell &dest);
165 virtual int i_psh16(u16_t op);
166 virtual int i_pul16(class cl_memory_cell &dest);
167 virtual int movw_imid(void);
168 virtual int movb_imid(void);
169 virtual int movw_exid(void);
170 virtual int movb_exid(void);
171 virtual int movw_idid(void);
172 virtual int movb_idid(void);
173 virtual int movw_imex(void);
174 virtual int movb_imex(void);
175 virtual int movw_exex(void);
176 virtual int movb_exex(void);
177 virtual int movw_idex(void);
178 virtual int movb_idex(void);
180 // BRANCH
181 virtual int call_e(void);
182 virtual int call_id(void);
183 virtual int brset(class cl_memory_cell &m);
184 virtual int brset_d(void);
185 virtual int brset_id(void);
186 virtual int brset_e(void);
187 virtual int brclr(class cl_memory_cell &m);
188 virtual int brclr_d(void);
189 virtual int brclr_id(void);
190 virtual int brclr_e(void);
191 virtual int branch(t_addr a, bool cond);
192 virtual int jump(t_addr a);
193 virtual int bsr(void);
194 virtual int jsr(t_addr a);
195 virtual int rtc(void);
196 virtual int rts(void);
197 virtual int swi(void);
198 virtual int rti(void);
199 virtual int lbranch(u8_t code);
200 virtual int loop(u8_t code);
202 // OTHER
203 virtual int andcc(u8_t op);
204 virtual int orcc(u8_t op);
205 virtual int lea(class cl_memory_cell &dest);
209 enum hc12cpu_cfg {
210 hc12_cpu_nuof = 0
213 class cl_hc12_cpu: public cl_hw
215 protected:
216 class cl_m68hc12 *muc;
217 class cl_memory_cell *dpage, *ppage, *epage, *windef;
218 public:
219 cl_hc12_cpu(class cl_uc *auc);
220 virtual int init(void);
221 virtual void reset(void);
222 virtual void print_info(class cl_console_base *con);
223 virtual t_mem ppage_write(u8_t val);
224 virtual u8_t ppage_read(void) { return ppage->R(); }
228 #endif
230 /* End of m68hc12.src/m68hc12cl.h */