[ucsim] Update email and file info, fix stm8 flash controller
[sdcc.git] / sdcc / sim / ucsim / src / sims / i8048.src / branch.cc
blob97459f8b15f27d12449f60d5e29813afe4c0d920
1 /*
2 * Simulator of microcontrollers (branch.cc)
4 * Copyright (C) 2022 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 #include "i8020cl.h"
31 int
32 cl_i8020::jmp(MP)
34 u16_t a;
35 a= (code&0xe0)<<3;
36 a+= fetch();
37 if (A11) a|= 0x800;
38 PC= a;
39 return resGO;
42 int
43 CL2::call(MP)
45 u16_t a= (code&0xe0)<<3;
46 a+= fetch();
47 if (A11) a|= 0x800;
48 push();
49 PC= a;
50 return resGO;
53 int
54 CL2::RET(MP)
56 PC= pop(false);
57 return resGO;
61 int
62 CL2::RETR(MP)
64 PC= pop(true);
65 return resGO;
69 int
70 CL2::jb(MP)
72 u8_t a= fetch();
73 u8_t m= 1<<((code>>5)&7);
74 if (rA & m)
76 PC&= 0xf00;
77 PC|= a;
79 return resGO;
82 int
83 CL2::jif(bool cond)
85 u8_t a= fetch();
86 if (cond)
88 PC&= 0xf00;
89 PC|= a;
91 return resGO;
95 int
96 CL2::JNZ(MP)
98 u8_t a= fetch();
99 if (rA)
101 PC&= 0xf00;
102 PC|= a;
104 return resGO;
110 CL2::JZ(MP)
112 u8_t a= fetch();
113 if (!rA)
115 PC&= 0xf00;
116 PC|= a;
118 return resGO;
124 CL2::JNC(MP)
126 u8_t a= fetch();
127 if (!(psw & flagC))
129 PC&= 0xf00;
130 PC|= a;
132 return resGO;
138 CL2::JC(MP)
140 u8_t a= fetch();
141 if (psw & flagC)
143 PC&= 0xf00;
144 PC|= a;
146 return resGO;
152 CL2::JT1(MP)
154 u8_t a= fetch();
155 if (cpu->cfg_read(i8020cpu_t1))
157 PC&= 0xf00;
158 PC|= a;
160 return resGO;
165 CL2::JMPPIA(MP)
167 u16_t a= (PC&=0xf00)|rA;
168 PC|= rom->read(a);
169 return resGO;
173 CL2::djnz(MP)
175 u8_t r= (code>>5)&7;
176 u8_t a= fetch();
177 R[r]->W(R[r]->R() - 1);
178 if (R[r] != 0)
180 PC&= 0xf00;
181 PC+= a;
183 return resGO;
187 /* End of i8048.src/branch.cc */