66 write(address, operand);
76 uint16_t result =
A + value +
PSW.
C;
77 PSW.
V = ((
A ^ result) & (value ^ result) & 0x80) != 0;
78 PSW.
H = ((
A & 0xf) + (value & 0xf) +
PSW.
C) > 0xf;
79 PSW.
C = (result > 0xFF);
82 PSW.
N = (
A & 0x80) != 0;
87 uint8_t applyOn =
read(dest);
88 int result = applyOn + operand +
PSW.
C;
89 PSW.
V = ((applyOn & 0x80) == (operand & 0x80)) &&
90 ((operand & 0x80) != (result & 0x80));
91 PSW.
H = ((applyOn & 0xf) + (operand & 0xf) +
PSW.
C) > 0xf;
92 PSW.
C = result > 0xff;
93 write(dest, result & 0xFF);
94 PSW.
Z = ((result & 0xFF) == 0);
95 PSW.
N = (result & 0x80) != 0;
100 uint8_t value =
read(
adr) ^ 0xff;
101 int result =
A + value +
PSW.
C;
102 PSW.
V = ((
A & 0x80) == (value & 0x80)) && ((value & 0x80) != (result & 0x80));
103 PSW.
H = ((
A & 0xf) + (value & 0xf) +
PSW.
C) > 0xf;
104 PSW.
C = result > 0xff;
107 PSW.
N = (
A & 0x80) != 0;
113 uint8_t applyOn =
read(dest);
114 int result = applyOn + operand +
PSW.
C;
115 PSW.
V = ((applyOn & 0x80) == (operand & 0x80)) &&
116 ((operand & 0x80) != (result & 0x80));
117 PSW.
H = ((applyOn & 0xF) + (operand & 0xF) +
PSW.
C) > 0xF;
118 PSW.
C = result > 0xFF;
119 write(dest, result & 0xFF);
120 PSW.
Z = ((result & 0xFF) == 0);
121 PSW.
N = (result & 0x80) != 0;
130 uint8_t value =
read(
adr) ^ 0xff;
131 int result =
A + value + 1;
132 PSW.
C = result > 0xff;
133 PSW.
Z = ((result & 0xFF) == 0);
134 PSW.
N = (result & 0x80) != 0;
139 uint8_t value =
read(
adr) ^ 0xff;
140 int result =
X + value + 1;
141 PSW.
C = result > 0xff;
142 PSW.
Z = ((result & 0xFF) == 0);
143 PSW.
N = (result & 0x80) != 0;
148 uint8_t value =
read(
adr) ^ 0xff;
149 int result =
Y + value + 1;
150 PSW.
C = result > 0xff;
151 PSW.
Z = ((result & 0xFF) == 0);
152 PSW.
N = (result & 0x80) != 0;
158 int result =
read(dst) + value + 1;
159 PSW.
C = result > 0xff;
161 PSW.
Z = ((result & 0xFF) == 0);
162 PSW.
N = (result & 0x80) != 0;
173 PSW.
N = (
A & 0x80) != 0;
178 uint8_t result =
read(dest) & operand;
180 PSW.
Z = (result == 0);
181 PSW.
N = (result & 0x80) != 0;
188 PSW.
N = (
A & 0x80) != 0;
193 uint8_t result =
read(dst) | value;
195 PSW.
Z = (result == 0);
196 PSW.
N = (result & 0x80) != 0;
203 PSW.
N = (
A & 0x80) != 0;
208 uint8_t result =
read(dest) ^ operand;
210 PSW.
Z = (result == 0);
211 PSW.
N = (result & 0x80) != 0;
222 PSW.
C = (val & 0x80) != 0;
226 PSW.
N = (val & 0x80) != 0;
233 PSW.
C = (val & 0x01) != 0;
237 PSW.
N = (val & 0x80) != 0;
244 bool newC = (val & 0x80) != 0;
245 val = (val << 1) |
PSW.
C;
249 PSW.
N = (val & 0x80) != 0;
256 bool newC = (val & 1) != 0;
257 val = (val >> 1) | (
PSW.
C << 7);
261 PSW.
N = (val & 0x80) != 0;
275 PSW.
N = (val & 0x80) != 0;
285 PSW.
N = (val & 0x80) != 0;
290 uint8_t value = isImmediate ?
imm() : operand;
291 value = ((value & 0xF0) >> 4) | ((value & 0x0F) << 4);
292 PSW.
Z = (value == 0);
293 PSW.
N = (value & 0x80) != 0;
303 PSW.
Z = (operand == 0);
304 PSW.
N = (operand & 0x8000) != 0;
310 PSW.
Z = (operand == 0);
311 PSW.
N = (operand & 0x8000) != 0;
317 PSW.
Z = (operand == 0);
318 PSW.
N = (operand & 0x8000) != 0;
323 uint32_t result = dest + operand;
324 PSW.
C = (result > 0xFFFF);
325 PSW.
Z = ((result & 0xFFFF) == 0);
326 PSW.
N = (result & 0x8000) != 0;
327 PSW.
V = ((dest ^ result) & (operand ^ result) & 0x8000) != 0;
328 PSW.
H = ((dest & 0xfff) + (operand & 0xfff)) > 0xfff;
329 dest = result & 0xFFFF;
334 uint32_t result = dest - operand;
335 PSW.
C = (result <= 0xFFFF);
336 PSW.
Z = ((result & 0xFFFF) == 0);
337 PSW.
N = (result & 0x8000) != 0;
338 PSW.
V = ((dest ^ result) & (dest ^ operand) & 0x8000) != 0;
339 PSW.
H = ((dest & 0xfff) - (operand & 0xfff)) >= 0;
340 dest = result & 0xFFFF;
345 uint32_t result =
YA - operand;
346 PSW.
C = (result <= 0xFFFF);
347 PSW.
Z = ((result & 0xFFFF) == 0);
348 PSW.
N = (result & 0x8000) != 0;
357 uint16_t result =
A * operand;
359 PSW.
Z = (result == 0);
360 PSW.
N = (result & 0x8000) != 0;
371 uint8_t quotient =
A / operand;
372 uint8_t remainder =
A % operand;
375 PSW.
Z = (quotient == 0);
376 PSW.
N = (quotient & 0x80) != 0;
422 if (operand & (1 << bit))
427 if (!(operand & (1 << bit)))
440 uint16_t return_address =
PC + 2;
447 uint16_t return_address =
PC + 2;
454 uint16_t return_address =
PC + 2;
457 PC = 0xFFDE + offset;
494 operand |= (1 << bit);
498 operand &= ~(1 << bit);
502 PSW.
C = (operand & (1 << bit)) != 0;
503 operand |= (1 << bit);
507 PSW.
C = (operand & (1 << bit)) != 0;
508 operand &= ~(1 << bit);
512 operand &= (1 << bit);
513 PSW.
Z = (operand == 0);
514 PSW.
N = (operand & 0x80) != 0;
518 operand |= (1 << bit);
519 PSW.
Z = (operand == 0);
520 PSW.
N = (operand & 0x80) != 0;
524 operand ^= (1 << bit);
525 PSW.
Z = (operand == 0);
526 PSW.
N = (operand & 0x80) != 0;
530 operand ^= (1 << bit);
531 PSW.
Z = (operand == 0);
532 PSW.
N = (operand & 0x80) != 0;
536 PSW.
C = (operand & (1 << bit)) != 0;
537 operand |= (1 << bit);
void CMPM(uint16_t dst, uint8_t value)
void SUBW(uint16_t &dest, uint16_t operand)
void PCALL(uint8_t offset)
void JMP(uint16_t address)
uint8_t read(uint16_t address)
void NOT1(uint8_t bit, uint8_t &operand)
void AND1(uint8_t bit, uint8_t &operand)
void ANDM(uint16_t dest, uint8_t operand)
void MOVW(uint16_t &dest, uint16_t operand)
void EORM(uint16_t dest, uint8_t operand)
void DEC(uint16_t operand)
void DIV(uint8_t operand)
void EOR1(uint8_t bit, uint8_t &operand)
void SBCM(uint16_t &dest, uint8_t operand)
void SET1(uint8_t bit, uint8_t &operand)
void push_byte(uint8_t value)
void TCLR1(uint8_t bit, uint8_t &operand)
uint8_t FlagsToByte(Flags flags)
void TCALL(uint8_t offset)
void ROL(uint16_t operand)
void MOV_ADDR(uint16_t address, uint8_t operand)
void write(uint16_t address, uint8_t value)
void XCN(uint8_t operand, bool isImmediate=false)
void PUSH(uint8_t operand)
void ADDW(uint16_t &dest, uint16_t operand)
void INCW(uint16_t &operand)
void BBC(uint8_t bit, uint8_t operand)
void CALL(uint16_t address)
void DECW(uint16_t &operand)
void push_word(uint16_t value)
void BBS(uint8_t bit, uint8_t operand)
uint16_t read_word(uint16_t address)
void POP(uint8_t &operand)
void ASL(uint16_t operand)
void CLR1(uint8_t bit, uint8_t &operand)
void ADCM(uint16_t &dest, uint8_t operand)
void OR1(uint8_t bit, uint8_t &operand)
void CMPW(uint16_t operand)
void MOV1(uint8_t bit, uint8_t &operand)
void TSET1(uint8_t bit, uint8_t &operand)
void ORM(uint16_t dest, uint8_t operand)
Flags ByteToFlags(uint8_t byte)
void MUL(uint8_t operand)
std::function< void(bool)> idle