[ucsim] Redesing use of OPT flag
[sdcc.git] / sdcc / sim / ucsim / m6800.src / imove.cc
blobe117570fe584b25dd559c2229c2782c868dc80f5
1 /*
2 * Simulator of microcontrollers (imove.cc)
4 * Copyright (C) @@S@@,@@Y@@ Drotos Daniel, Talker Bt.
5 *
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
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. */
27 #include "m6800cl.h"
30 int
31 cl_m6800::clr(class cl_memory_cell &dest)
33 u8_t f= rF & ~(flagN|flagV|flagC);
34 dest.W(0);
35 f|= flagZ;
36 cCC.W(f);
37 return resGO;
40 int
41 cl_m6800::lda(class cl_memory_cell &dest, u8_t op)
43 u8_t f= rF & ~(flagN|flagV|flagC);
44 dest.W(op);
45 if (!op) f|= flagZ;
46 if (op&0x80) f|= flagN;
47 cCC.W(f);
48 return resGO;
51 int
52 cl_m6800::sta(class cl_memory_cell &dest, u8_t op)
54 u8_t f= rF & ~(flagN|flagV|flagC);
55 dest.W(op);
56 if (!op) f|= flagZ;
57 if (op&0x80) f|= flagN;
58 cCC.W(f);
59 return resGO;
62 int
63 cl_m6800::ldsx(class cl_cell16 &dest, u16_t op)
65 u8_t f= rF & ~(flagN|flagV|flagC);
66 dest.W(op);
67 if (!op) f|= flagZ;
68 if (op&0x8000) f|= flagN;
69 cCC.W(f);
70 return resGO;
73 int
74 cl_m6800::stsx(t_addr a, u16_t op)
76 u8_t f= rF & ~(flagN|flagV|flagC);
77 rom->write(a, op>>8);
78 rom->write(a+1, op&0xff);
79 vc.wr+= 2;
80 if (!op) f|= flagZ;
81 if (op&0x8000) f|= flagN;
82 cCC.W(f);
83 return resGO;
87 int
88 cl_m6800::TAP(t_mem code)
90 cF.W(rA);
91 return resGO;
94 int
95 cl_m6800::TPA(t_mem code)
97 cA.W(rF);
98 return resGO;
102 cl_m6800::TAB(t_mem code)
104 u8_t f= rCC & ~(flagN|flagZ|flagV);
105 cB.W(rA);
106 if (!rA) f|= flagZ;
107 if (rA&0x80) f|= flagN;
108 cCC.W(f);
109 return resGO;
113 cl_m6800::TBA(t_mem code)
115 u8_t f= rF & ~(flagN|flagZ|flagV);
116 cA.W(rB);
117 if (!rB) f|= flagZ;
118 if (rB&0x80) f|= flagN;
119 cF.W(f);
120 return resGO;
124 cl_m6800::TSX(t_mem code)
126 cIX.W(rSP+1);
127 return resGO;
131 cl_m6800::PULA(t_mem code)
133 cSP.W(rSP+1);
134 cA.W(rom->read(rSP));
135 vc.rd++;
136 return resGO;
140 cl_m6800::PULB(t_mem code)
142 cSP.W(rSP+1);
143 cB.W(rom->read(rSP));
144 vc.rd++;
145 return resGO;
149 cl_m6800::TXS(t_mem code)
151 cSP.W(rIX-1);
152 return resGO;
156 cl_m6800::PSHA(t_mem code)
158 rom->write(rSP, rA);
159 cSP.W(rSP-1);
160 vc.wr++;
161 return resGO;
165 cl_m6800::PSHB(t_mem code)
167 rom->write(rSP, rB);
168 cSP.W(rSP-1);
169 vc.wr++;
170 return resGO;
174 /* End of m6800.src/imove.cc */