2 * Simulator of microcontrollers (ibranch.cc)
4 * Copyright (C) 2020 Drotos Daniel
6 * To contact author send email to dr.dkdb@gmail.com
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
35 cl_rxk::DJNZ(t_mem code
)
41 PC
= (PC
+ r
) & 0xffff;
47 cl_rxk::JR(t_mem code
)
50 PC
= (PC
+ r
) & 0xffff;
56 cl_rxk::LJP(t_mem code
)
69 cl_rxk::CALL_mn(t_mem code
)
74 rom
->write(--rSP
, PC
>>8);
75 rom
->write(--rSP
, PC
);
84 cl_rxk::LCALL_lmn(t_mem code
)
91 rom
->write(rSP
, rXPC
);
93 rom
->write(rSP
, PC
>>8);
104 cl_rxk::rst_v(t_mem code
)
106 if ((jaj
|| (juj
&1)) && (code
== 0xef)) return resGO
;
107 u8_t l
= (code
&0x38) << 1;
109 rom
->write(rSP
, PC
>>8);
120 cl_rxk::jr_cc(bool cond
)
124 PC
= (PC
+ r
) & 0xffff;
130 cl_rxk::ret_f(bool f
)
147 cl_rxk::jp_f_mn(bool f
)
161 cl_rxk::LRET(t_mem code
)
177 cl_rxk::RETI(t_mem code
)
198 cl_r3ka::SYSCALL(t_mem code
)
201 rom
->write(rSP
, PC
>>8);
204 PC
= rIIR
* 256 + 0x60;
211 cl_r4k::DWJNZ(t_mem code
)
217 PC
= (PC
+ e
) & 0xffff;
223 cl_r4k::lljp_cx(t_mem code
)
225 u8_t cx
= (code
>>3) & 0x3;
226 bool cond
= false, z
, s
, v
, c
, sxv
;
231 sxv
= (!s
&& v
) || (s
&& !v
);
234 case 0: // GT: (Z or (S xor V))=0
237 case 1: // GTU: ((C=0) and (Z=0))=1
240 case 2: // LT: (S xor V)=1
251 lxpc
+= fetch() * 256;
263 cl_r4k::lljp_cc(t_mem code
)
265 u8_t cc
= (code
>>3) & 0x3;
266 bool cond
= false, z
, c
;
288 lxpc
+= fetch() * 256;
300 cl_r4k::jre_cx_cc(bool cond
)
307 PC
= (PC
+ ee
) & 0xffff;
313 cl_r4k::CALL_iIR(t_mem code
)
316 rom
->write(--a
, PC
>>8);
326 cl_r4k::CALL_iHL(t_mem code
)
329 rom
->write(--a
, PC
>>8);
339 cl_r4k::LLRET(t_mem code
)
344 l
+= rom
->read(a
++)*256;
346 h
+= rom
->read(a
++)*256;
356 cl_r4k::FSYSCALL(t_mem code
)
359 rom
->write(--a
, PC
>>8);
361 rom
->write(--a
, rSU
);
372 cl_r4k::SYSRET(t_mem code
)
375 cSU
.W(rom
->read(a
++));
377 v
+= rom
->read(a
++)*256;
386 cl_r4k::LLCALL_iJKHL(t_mem code
)
388 u16_t a
= rSP
, x
= LXPC
->get();
389 rom
->write(--a
, x
>>8);
391 rom
->write(--a
, PC
>>8);
401 cl_r4k::LLJP_lxpcmn(t_mem code
)
415 cl_r4k::LLCALL_lxpcmn(t_mem code
)
421 rom
->write(--a
, lxpc
>>8);
422 rom
->write(--a
, lxpc
);
424 rom
->write(--a
, mn
>>8);
441 cl_r4k::JRE_ee(t_mem code
)
454 cl_r4k::jr_cx_e(bool cond
)
458 PC
= (PC
+ e
) & 0xffff;
464 cl_r4k::jp_cx_mn(bool cond
)
475 /* End of rxk.src/ibranch.cc */